feat: update string formats to differ between appliance and server

On VC-4, ALL statements have to go to the Error Log. With this change, all messages will go to the Error log at the Notice level on VC-4 only with the Essentials appdebug level added to the message. This should aid in filtering out messages from the error log
This commit is contained in:
Andrew Welker
2022-11-04 13:34:36 -06:00
parent 4890b167ab
commit 1e2fa36390

View File

@@ -367,7 +367,19 @@ namespace PepperDash.Core
/// <param name="items">Object parameters</param>
public static void Console(uint level, string format, params object[] items)
{
if (Level >= level)
if (CrestronEnvironment.DevicePlatform == eDevicePlatform.Server)
{
var logString = string.Format("[level {0}] {1}", level, string.Format(format, items));
LogError(ErrorLogLevel.Notice, logString);
return;
}
if(Level < level)
{
return;
}
CrestronConsole.PrintLine("[{0}]App {1}:{2}", DateTime.Now.ToString("HH:mm:ss.fff"), InitialParametersClass.ApplicationNumber,
string.Format(format, items));
}
@@ -442,7 +454,8 @@ namespace PepperDash.Core
/// <param name="str"></param>
public static void LogError(ErrorLogLevel errorLogLevel, string str)
{
var msg = string.Format("App {0}:{1}", InitialParametersClass.ApplicationNumber, str);
var msg = CrestronEnvironment.DevicePlatform == eDevicePlatform.Appliance ? string.Format("App {0}:{1}", InitialParametersClass.ApplicationNumber, str) : string.Format("Room {0}:{1}", InitialParametersClass.RoomId, str);
switch (errorLogLevel)
{
case ErrorLogLevel.Error:
@@ -482,7 +495,11 @@ namespace PepperDash.Core
//if (!Directory.Exists(dir))
// Directory.Create(dir);
using (var sw = new StreamWriter(GetMemoryFileName()))
var fileName = GetMemoryFileName();
Console(0, ErrorLogLevel.Notice, "Loading debug settings file from {0}", fileName);
using (var sw = new StreamWriter(fileName))
{
var json = JsonConvert.SerializeObject(_contexts);
sw.Write(json);
@@ -525,7 +542,7 @@ namespace PepperDash.Core
return string.Format(@"\user\debugSettings\program{0}", InitialParametersClass.ApplicationNumber);
}
return string.Format("", InitialParametersClass.RoomId);
return string.Format("{0}{1}user{1}debugSettings{1}{2}.json",Directory.GetApplicationRootDirectory(), Path.DirectorySeparatorChar, InitialParametersClass.RoomId);
}
private static void CheckForMigration()
@@ -538,7 +555,7 @@ namespace PepperDash.Core
{
Console(0, ErrorLogLevel.Notice,
String.Format(
@"Debug settings file not found at \nvram\debugSettings\program{0}. Attempting to use file at \user\debugSettings\program{0}",
@"Debug settings file migration not necessary. Using file at \user\debugSettings\program{0}",
InitialParametersClass.ApplicationNumber));
return;
}