Adds back in crestron console print statements when running on appliance

This commit is contained in:
Neil Dorin
2023-11-01 09:39:46 -06:00
parent 90e1dc78ac
commit c9f3d77e0b

View File

@@ -11,8 +11,6 @@ using PepperDash.Core.DebugThings;
using Serilog; using Serilog;
using Serilog.Core; using Serilog.Core;
using Serilog.Events; using Serilog.Events;
using Serilog.Formatting.Display;
using System.Runtime.Serialization;
namespace PepperDash.Core namespace PepperDash.Core
{ {
@@ -85,6 +83,8 @@ namespace PepperDash.Core
private const int SaveTimeoutMs = 30000; private const int SaveTimeoutMs = 30000;
private static bool _runningOnAppliance = CrestronEnvironment.DevicePlatform == eDevicePlatform.Appliance;
/// <summary> /// <summary>
/// Version for the currently loaded PepperDashCore dll /// Version for the currently loaded PepperDashCore dll
/// </summary> /// </summary>
@@ -104,7 +104,7 @@ namespace PepperDash.Core
static Debug() static Debug()
{ {
_consoleLoggingLevelSwitch = new LoggingLevelSwitch(); _consoleLoggingLevelSwitch = new LoggingLevelSwitch(initialMinimumLevel: LogEventLevel.Information);
_websocketLoggingLevelSwitch = new LoggingLevelSwitch(); _websocketLoggingLevelSwitch = new LoggingLevelSwitch();
// Instantiate the root logger // Instantiate the root logger
@@ -218,6 +218,8 @@ namespace PepperDash.Core
if (programEventType == eProgramStatusEventType.Stopping) if (programEventType == eProgramStatusEventType.Stopping)
{ {
_logger.CloseAndFlush();
if (_saveTimer != null) if (_saveTimer != null)
{ {
_saveTimer.Stop(); _saveTimer.Stop();
@@ -430,11 +432,6 @@ namespace PepperDash.Core
} }
private static void Log(uint level, string format, params object[] items)
{
}
/// <summary> /// <summary>
/// Prints message to console if current debug level is equal to or higher than the level of this message. /// Prints message to console if current debug level is equal to or higher than the level of this message.
/// Uses CrestronConsole.PrintLine. /// Uses CrestronConsole.PrintLine.
@@ -454,8 +451,13 @@ namespace PepperDash.Core
_logger.Write((LogEventLevel)level, format, items); _logger.Write((LogEventLevel)level, format, items);
//CrestronConsole.PrintLine("[{0}]App {1}:{2}", DateTime.Now.ToString("HH:mm:ss.fff"), InitialParametersClass.ApplicationNumber, if (_runningOnAppliance)
// string.Format(format, items)); {
CrestronConsole.PrintLine("[{0}]App {1} Lvl {2}:{3}", DateTime.Now.ToString("HH:mm:ss.fff"),
InitialParametersClass.ApplicationNumber,
level,
string.Format(format, items));
}
} }
/// <summary> /// <summary>
@@ -467,8 +469,8 @@ namespace PepperDash.Core
log.Write((LogEventLevel)level, format, items); log.Write((LogEventLevel)level, format, items);
//if (Level >= level) if (Level >= level)
// Console(level, "[{0}] {1}", dev.Key, string.Format(format, items)); Console(level, "[{0}] {1}", dev.Key, string.Format(format, items));
} }
/// <summary> /// <summary>
@@ -490,10 +492,10 @@ namespace PepperDash.Core
log.Write((LogEventLevel)level, format, items); log.Write((LogEventLevel)level, format, items);
//if (Level >= level) if (Level >= level)
//{ {
// Console(level, str); Console(level, str);
//} }
} }
/// <summary> /// <summary>
@@ -546,7 +548,7 @@ namespace PepperDash.Core
public static void LogError(ErrorLogLevel errorLogLevel, string str) public static void LogError(ErrorLogLevel errorLogLevel, string str)
{ {
var msg = CrestronEnvironment.DevicePlatform == eDevicePlatform.Appliance ? string.Format("App {0}:{1}", InitialParametersClass.ApplicationNumber, str) : string.Format("Room {0}:{1}", InitialParametersClass.RoomId, str); var msg = _runningOnAppliance ? string.Format("App {0}:{1}", InitialParametersClass.ApplicationNumber, str) : string.Format("Room {0}:{1}", InitialParametersClass.RoomId, str);
switch (errorLogLevel) switch (errorLogLevel)
{ {
case ErrorLogLevel.Error: case ErrorLogLevel.Error: