mirror of
https://github.com/PepperDash/PepperDashCore.git
synced 2026-01-11 19:44:44 +00:00
fix: add console log level recall
This commit is contained in:
@@ -21,6 +21,7 @@ namespace PepperDash.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static class Debug
|
public static class Debug
|
||||||
{
|
{
|
||||||
|
private static string LevelStoreKey = "ConsoleDebugLevel";
|
||||||
private static Dictionary<uint, LogEventLevel> _logLevels = new Dictionary<uint, LogEventLevel>()
|
private static Dictionary<uint, LogEventLevel> _logLevels = new Dictionary<uint, LogEventLevel>()
|
||||||
{
|
{
|
||||||
{0, LogEventLevel.Information },
|
{0, LogEventLevel.Information },
|
||||||
@@ -101,7 +102,9 @@ namespace PepperDash.Core
|
|||||||
|
|
||||||
static Debug()
|
static Debug()
|
||||||
{
|
{
|
||||||
_consoleLoggingLevelSwitch = new LoggingLevelSwitch(initialMinimumLevel: LogEventLevel.Information);
|
var defaultConsoleLevel = GetStoredLogEventLevel();
|
||||||
|
|
||||||
|
_consoleLoggingLevelSwitch = new LoggingLevelSwitch(initialMinimumLevel: defaultConsoleLevel);
|
||||||
_consoleLoggingLevelSwitch.MinimumLevelChanged += (sender, args) =>
|
_consoleLoggingLevelSwitch.MinimumLevelChanged += (sender, args) =>
|
||||||
{
|
{
|
||||||
Console(0, "Console debug level set to {0}", _consoleLoggingLevelSwitch.MinimumLevel);
|
Console(0, "Console debug level set to {0}", _consoleLoggingLevelSwitch.MinimumLevel);
|
||||||
@@ -187,6 +190,24 @@ namespace PepperDash.Core
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static LogEventLevel GetStoredLogEventLevel()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var result = CrestronDataStoreStatic.GetLocalUintValue(LevelStoreKey, out uint logLevel);
|
||||||
|
|
||||||
|
if(result != CrestronDataStore.CDS_ERROR.CDS_SUCCESS || logLevel > 5 || logLevel < 0)
|
||||||
|
{
|
||||||
|
return LogEventLevel.Information;
|
||||||
|
}
|
||||||
|
|
||||||
|
return _logLevels[logLevel];
|
||||||
|
} catch
|
||||||
|
{
|
||||||
|
return LogEventLevel.Information;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static void GetVersion()
|
private static void GetVersion()
|
||||||
{
|
{
|
||||||
var assembly = Assembly.GetExecutingAssembly();
|
var assembly = Assembly.GetExecutingAssembly();
|
||||||
|
|||||||
Reference in New Issue
Block a user