mirror of
https://github.com/PepperDash/PepperDashCore.git
synced 2026-04-12 03:57:08 +00:00
fix: add console log level recall
This commit is contained in:
parent
ada8b7e162
commit
32caa005a3
1 changed files with 22 additions and 1 deletions
|
|
@ -21,6 +21,7 @@ namespace PepperDash.Core
|
|||
/// </summary>
|
||||
public static class Debug
|
||||
{
|
||||
private static string LevelStoreKey = "ConsoleDebugLevel";
|
||||
private static Dictionary<uint, LogEventLevel> _logLevels = new Dictionary<uint, LogEventLevel>()
|
||||
{
|
||||
{0, LogEventLevel.Information },
|
||||
|
|
@ -101,7 +102,9 @@ namespace PepperDash.Core
|
|||
|
||||
static Debug()
|
||||
{
|
||||
_consoleLoggingLevelSwitch = new LoggingLevelSwitch(initialMinimumLevel: LogEventLevel.Information);
|
||||
var defaultConsoleLevel = GetStoredLogEventLevel();
|
||||
|
||||
_consoleLoggingLevelSwitch = new LoggingLevelSwitch(initialMinimumLevel: defaultConsoleLevel);
|
||||
_consoleLoggingLevelSwitch.MinimumLevelChanged += (sender, args) =>
|
||||
{
|
||||
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()
|
||||
{
|
||||
var assembly = Assembly.GetExecutingAssembly();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue