mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-01-11 19:44:52 +00:00
fix: use correct overload for logging at levels
Some overloads that had the first argument as an Exception were calling the _logger.Write method with a null where the message template should have been, causing messages logged with that overload to be swallowed and not logged.
This commit is contained in:
@@ -1,4 +1,8 @@
|
|||||||
using Crestron.SimplSharp;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using Crestron.SimplSharp;
|
||||||
using Crestron.SimplSharp.CrestronDataStore;
|
using Crestron.SimplSharp.CrestronDataStore;
|
||||||
using Crestron.SimplSharp.CrestronIO;
|
using Crestron.SimplSharp.CrestronIO;
|
||||||
using Crestron.SimplSharp.CrestronLogger;
|
using Crestron.SimplSharp.CrestronLogger;
|
||||||
@@ -11,10 +15,6 @@ using Serilog.Events;
|
|||||||
using Serilog.Formatting.Compact;
|
using Serilog.Formatting.Compact;
|
||||||
using Serilog.Formatting.Json;
|
using Serilog.Formatting.Json;
|
||||||
using Serilog.Templates;
|
using Serilog.Templates;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
|
|
||||||
namespace PepperDash.Core
|
namespace PepperDash.Core
|
||||||
{
|
{
|
||||||
@@ -48,6 +48,9 @@ namespace PepperDash.Core
|
|||||||
|
|
||||||
private static readonly LoggingLevelSwitch _fileLevelSwitch;
|
private static readonly LoggingLevelSwitch _fileLevelSwitch;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the minimum log level for the websocket sink.
|
||||||
|
/// </summary>
|
||||||
public static LogEventLevel WebsocketMinimumLogLevel
|
public static LogEventLevel WebsocketMinimumLogLevel
|
||||||
{
|
{
|
||||||
get { return _websocketLoggingLevelSwitch.MinimumLevel; }
|
get { return _websocketLoggingLevelSwitch.MinimumLevel; }
|
||||||
@@ -55,6 +58,9 @@ namespace PepperDash.Core
|
|||||||
|
|
||||||
private static readonly DebugWebsocketSink _websocketSink;
|
private static readonly DebugWebsocketSink _websocketSink;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the websocket sink for debug logging.
|
||||||
|
/// </summary>
|
||||||
public static DebugWebsocketSink WebsocketSink
|
public static DebugWebsocketSink WebsocketSink
|
||||||
{
|
{
|
||||||
get { return _websocketSink; }
|
get { return _websocketSink; }
|
||||||
@@ -91,29 +97,33 @@ namespace PepperDash.Core
|
|||||||
|
|
||||||
private const int SaveTimeoutMs = 30000;
|
private const int SaveTimeoutMs = 30000;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Indicates whether the system is running on an appliance.
|
||||||
|
/// </summary>
|
||||||
public static bool IsRunningOnAppliance = CrestronEnvironment.DevicePlatform == eDevicePlatform.Appliance;
|
public static bool IsRunningOnAppliance = CrestronEnvironment.DevicePlatform == eDevicePlatform.Appliance;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the PepperDashCoreVersion
|
/// Gets or sets the PepperDashCoreVersion
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string PepperDashCoreVersion { get; private set; }
|
public static string PepperDashCoreVersion { get; private set; }
|
||||||
|
|
||||||
private static CTimer _saveTimer;
|
private static CTimer _saveTimer;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// When true, the IncludedExcludedKeys dict will contain keys to include.
|
/// When true, the IncludedExcludedKeys dict will contain keys to include.
|
||||||
/// When false (default), IncludedExcludedKeys will contain keys to exclude.
|
/// When false (default), IncludedExcludedKeys will contain keys to exclude.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static bool _excludeAllMode;
|
private static bool _excludeAllMode;
|
||||||
|
|
||||||
//static bool ExcludeNoKeyMessages;
|
private static readonly Dictionary<string, object> IncludedExcludedKeys;
|
||||||
|
|
||||||
private static readonly Dictionary<string, object> IncludedExcludedKeys;
|
|
||||||
|
|
||||||
private static readonly LoggerConfiguration _defaultLoggerConfiguration;
|
private static readonly LoggerConfiguration _defaultLoggerConfiguration;
|
||||||
|
|
||||||
private static LoggerConfiguration _loggerConfiguration;
|
private static LoggerConfiguration _loggerConfiguration;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the logger configuration for the debug logging.
|
||||||
|
/// </summary>
|
||||||
public static LoggerConfiguration LoggerConfiguration => _loggerConfiguration;
|
public static LoggerConfiguration LoggerConfiguration => _loggerConfiguration;
|
||||||
|
|
||||||
static Debug()
|
static Debug()
|
||||||
@@ -128,7 +138,7 @@ namespace PepperDash.Core
|
|||||||
|
|
||||||
var defaultFileLogLevel = GetStoredLogEventLevel(FileLevelStoreKey);
|
var defaultFileLogLevel = GetStoredLogEventLevel(FileLevelStoreKey);
|
||||||
|
|
||||||
_consoleLoggingLevelSwitch = new LoggingLevelSwitch(initialMinimumLevel: defaultConsoleLevel);
|
_consoleLoggingLevelSwitch = new LoggingLevelSwitch(initialMinimumLevel: defaultConsoleLevel);
|
||||||
|
|
||||||
_websocketLoggingLevelSwitch = new LoggingLevelSwitch(initialMinimumLevel: defaultWebsocketLevel);
|
_websocketLoggingLevelSwitch = new LoggingLevelSwitch(initialMinimumLevel: defaultWebsocketLevel);
|
||||||
|
|
||||||
@@ -144,7 +154,7 @@ namespace PepperDash.Core
|
|||||||
|
|
||||||
CrestronConsole.PrintLine($"Saving log files to {logFilePath}");
|
CrestronConsole.PrintLine($"Saving log files to {logFilePath}");
|
||||||
|
|
||||||
var errorLogTemplate = CrestronEnvironment.DevicePlatform == eDevicePlatform.Appliance
|
var errorLogTemplate = CrestronEnvironment.DevicePlatform == eDevicePlatform.Appliance
|
||||||
? "{@t:fff}ms [{@l:u4}]{#if Key is not null}[{Key}]{#end} {@m}{#if @x is not null}\r\n{@x}{#end}"
|
? "{@t:fff}ms [{@l:u4}]{#if Key is not null}[{Key}]{#end} {@m}{#if @x is not null}\r\n{@x}{#end}"
|
||||||
: "[{@t:yyyy-MM-dd HH:mm:ss.fff}][{@l:u4}][{App}]{#if Key is not null}[{Key}]{#end} {@m}{#if @x is not null}\r\n{@x}{#end}";
|
: "[{@t:yyyy-MM-dd HH:mm:ss.fff}][{@l:u4}][{App}]{#if Key is not null}[{Key}]{#end} {@m}{#if @x is not null}\r\n{@x}{#end}";
|
||||||
|
|
||||||
@@ -155,7 +165,7 @@ namespace PepperDash.Core
|
|||||||
.WriteTo.Sink(new DebugConsoleSink(new ExpressionTemplate("[{@t:yyyy-MM-dd HH:mm:ss.fff}][{@l:u4}][{App}]{#if Key is not null}[{Key}]{#end} {@m}{#if @x is not null}\r\n{@x}{#end}")), levelSwitch: _consoleLoggingLevelSwitch)
|
.WriteTo.Sink(new DebugConsoleSink(new ExpressionTemplate("[{@t:yyyy-MM-dd HH:mm:ss.fff}][{@l:u4}][{App}]{#if Key is not null}[{Key}]{#end} {@m}{#if @x is not null}\r\n{@x}{#end}")), levelSwitch: _consoleLoggingLevelSwitch)
|
||||||
.WriteTo.Sink(_websocketSink, levelSwitch: _websocketLoggingLevelSwitch)
|
.WriteTo.Sink(_websocketSink, levelSwitch: _websocketLoggingLevelSwitch)
|
||||||
.WriteTo.Sink(new DebugErrorLogSink(new ExpressionTemplate(errorLogTemplate)), levelSwitch: _errorLogLevelSwitch)
|
.WriteTo.Sink(new DebugErrorLogSink(new ExpressionTemplate(errorLogTemplate)), levelSwitch: _errorLogLevelSwitch)
|
||||||
.WriteTo.File(new RenderedCompactJsonFormatter(), logFilePath,
|
.WriteTo.File(new RenderedCompactJsonFormatter(), logFilePath,
|
||||||
rollingInterval: RollingInterval.Day,
|
rollingInterval: RollingInterval.Day,
|
||||||
restrictedToMinimumLevel: LogEventLevel.Debug,
|
restrictedToMinimumLevel: LogEventLevel.Debug,
|
||||||
retainedFileCountLimit: CrestronEnvironment.DevicePlatform == eDevicePlatform.Appliance ? 30 : 60,
|
retainedFileCountLimit: CrestronEnvironment.DevicePlatform == eDevicePlatform.Appliance ? 30 : 60,
|
||||||
@@ -193,27 +203,27 @@ namespace PepperDash.Core
|
|||||||
|
|
||||||
CrestronConsole.PrintLine(msg);
|
CrestronConsole.PrintLine(msg);
|
||||||
|
|
||||||
LogMessage(LogEventLevel.Information,msg);
|
LogMessage(LogEventLevel.Information, msg);
|
||||||
|
|
||||||
|
IncludedExcludedKeys = new Dictionary<string, object>();
|
||||||
|
|
||||||
IncludedExcludedKeys = new Dictionary<string, object>();
|
|
||||||
|
|
||||||
if (CrestronEnvironment.RuntimeEnvironment == eRuntimeEnvironment.SimplSharpPro)
|
if (CrestronEnvironment.RuntimeEnvironment == eRuntimeEnvironment.SimplSharpPro)
|
||||||
{
|
{
|
||||||
// Add command to console
|
// Add command to console
|
||||||
CrestronConsole.AddNewConsoleCommand(SetDoNotLoadOnNextBootFromConsole, "donotloadonnextboot",
|
CrestronConsole.AddNewConsoleCommand(SetDoNotLoadOnNextBootFromConsole, "donotloadonnextboot",
|
||||||
"donotloadonnextboot:P [true/false]: Should the application load on next boot", ConsoleAccessLevelEnum.AccessOperator);
|
"donotloadonnextboot:P [true/false]: Should the application load on next boot", ConsoleAccessLevelEnum.AccessOperator);
|
||||||
|
|
||||||
CrestronConsole.AddNewConsoleCommand(SetDebugFromConsole, "appdebug",
|
CrestronConsole.AddNewConsoleCommand(SetDebugFromConsole, "appdebug",
|
||||||
"appdebug:P [0-5]: Sets the application's console debug message level",
|
"appdebug:P [0-5]: Sets the application's console debug message level",
|
||||||
ConsoleAccessLevelEnum.AccessOperator);
|
ConsoleAccessLevelEnum.AccessOperator);
|
||||||
CrestronConsole.AddNewConsoleCommand(ShowDebugLog, "appdebuglog",
|
CrestronConsole.AddNewConsoleCommand(ShowDebugLog, "appdebuglog",
|
||||||
"appdebuglog:P [all] Use \"all\" for full log.",
|
"appdebuglog:P [all] Use \"all\" for full log.",
|
||||||
ConsoleAccessLevelEnum.AccessOperator);
|
ConsoleAccessLevelEnum.AccessOperator);
|
||||||
CrestronConsole.AddNewConsoleCommand(s => CrestronLogger.Clear(false), "appdebugclear",
|
CrestronConsole.AddNewConsoleCommand(s => CrestronLogger.Clear(false), "appdebugclear",
|
||||||
"appdebugclear:P Clears the current custom log",
|
"appdebugclear:P Clears the current custom log",
|
||||||
ConsoleAccessLevelEnum.AccessOperator);
|
ConsoleAccessLevelEnum.AccessOperator);
|
||||||
CrestronConsole.AddNewConsoleCommand(SetDebugFilterFromConsole, "appdebugfilter",
|
CrestronConsole.AddNewConsoleCommand(SetDebugFilterFromConsole, "appdebugfilter",
|
||||||
"appdebugfilter [params]", ConsoleAccessLevelEnum.AccessOperator);
|
"appdebugfilter [params]", ConsoleAccessLevelEnum.AccessOperator);
|
||||||
}
|
}
|
||||||
|
|
||||||
CrestronEnvironment.ProgramStatusEventHandler += CrestronEnvironment_ProgramStatusEventHandler;
|
CrestronEnvironment.ProgramStatusEventHandler += CrestronEnvironment_ProgramStatusEventHandler;
|
||||||
@@ -224,7 +234,7 @@ namespace PepperDash.Core
|
|||||||
Level = context.Level;
|
Level = context.Level;
|
||||||
DoNotLoadConfigOnNextBoot = context.DoNotLoadOnNextBoot;
|
DoNotLoadConfigOnNextBoot = context.DoNotLoadOnNextBoot;
|
||||||
|
|
||||||
if(DoNotLoadConfigOnNextBoot)
|
if (DoNotLoadConfigOnNextBoot)
|
||||||
CrestronConsole.PrintLine(string.Format("Program {0} will not load config after next boot. Use console command go:{0} to load the config manually", InitialParametersClass.ApplicationNumber));
|
CrestronConsole.PrintLine(string.Format("Program {0} will not load config after next boot. Use console command go:{0} to load the config manually", InitialParametersClass.ApplicationNumber));
|
||||||
|
|
||||||
_consoleLoggingLevelSwitch.MinimumLevelChanged += (sender, args) =>
|
_consoleLoggingLevelSwitch.MinimumLevelChanged += (sender, args) =>
|
||||||
@@ -257,7 +267,7 @@ namespace PepperDash.Core
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var result = CrestronDataStoreStatic.GetLocalIntValue(levelStoreKey, out int logLevel);
|
var result = CrestronDataStoreStatic.GetLocalIntValue(levelStoreKey, out int logLevel);
|
||||||
|
|
||||||
if (result != CrestronDataStore.CDS_ERROR.CDS_SUCCESS)
|
if (result != CrestronDataStore.CDS_ERROR.CDS_SUCCESS)
|
||||||
{
|
{
|
||||||
@@ -265,14 +275,15 @@ namespace PepperDash.Core
|
|||||||
return LogEventLevel.Information;
|
return LogEventLevel.Information;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(logLevel < 0 || logLevel > 5)
|
if (logLevel < 0 || logLevel > 5)
|
||||||
{
|
{
|
||||||
CrestronConsole.PrintLine($"Stored Log level not valid for {levelStoreKey}: {logLevel}. Setting level to {LogEventLevel.Information}");
|
CrestronConsole.PrintLine($"Stored Log level not valid for {levelStoreKey}: {logLevel}. Setting level to {LogEventLevel.Information}");
|
||||||
return LogEventLevel.Information;
|
return LogEventLevel.Information;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (LogEventLevel)logLevel;
|
return (LogEventLevel)logLevel;
|
||||||
} catch (Exception ex)
|
}
|
||||||
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
CrestronConsole.PrintLine($"Exception retrieving log level for {levelStoreKey}: {ex.Message}");
|
CrestronConsole.PrintLine($"Exception retrieving log level for {levelStoreKey}: {ex.Message}");
|
||||||
return LogEventLevel.Information;
|
return LogEventLevel.Information;
|
||||||
@@ -284,7 +295,7 @@ namespace PepperDash.Core
|
|||||||
var assembly = Assembly.GetExecutingAssembly();
|
var assembly = Assembly.GetExecutingAssembly();
|
||||||
var ver =
|
var ver =
|
||||||
assembly
|
assembly
|
||||||
.GetCustomAttributes(typeof (AssemblyInformationalVersionAttribute), false);
|
.GetCustomAttributes(typeof(AssemblyInformationalVersionAttribute), false);
|
||||||
|
|
||||||
if (ver != null && ver.Length > 0)
|
if (ver != null && ver.Length > 0)
|
||||||
{
|
{
|
||||||
@@ -351,25 +362,25 @@ namespace PepperDash.Core
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(int.TryParse(levelString, out var levelInt))
|
if (int.TryParse(levelString, out var levelInt))
|
||||||
{
|
{
|
||||||
if(levelInt < 0 || levelInt > 5)
|
if (levelInt < 0 || levelInt > 5)
|
||||||
{
|
{
|
||||||
CrestronConsole.ConsoleCommandResponse($"Error: Unable to parse {levelString} to valid log level. If using a number, value must be between 0-5");
|
CrestronConsole.ConsoleCommandResponse($"Error: Unable to parse {levelString} to valid log level. If using a number, value must be between 0-5");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SetDebugLevel((uint) levelInt);
|
SetDebugLevel((uint)levelInt);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Enum.TryParse<LogEventLevel>(levelString, out var levelEnum))
|
if (Enum.TryParse<LogEventLevel>(levelString, out var levelEnum))
|
||||||
{
|
{
|
||||||
SetDebugLevel(levelEnum);
|
SetDebugLevel(levelEnum);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CrestronConsole.ConsoleCommandResponse($"Error: Unable to parse {levelString} to valid log level");
|
CrestronConsole.ConsoleCommandResponse($"Error: Unable to parse {levelString} to valid log level");
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
CrestronConsole.ConsoleCommandResponse("Usage: appdebug:P [0-5]");
|
CrestronConsole.ConsoleCommandResponse("Usage: appdebug:P [0-5]");
|
||||||
@@ -385,7 +396,7 @@ namespace PepperDash.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static void SetDebugLevel(uint level)
|
public static void SetDebugLevel(uint level)
|
||||||
{
|
{
|
||||||
if(!_logLevels.TryGetValue(level, out var logLevel))
|
if (!_logLevels.TryGetValue(level, out var logLevel))
|
||||||
{
|
{
|
||||||
logLevel = LogEventLevel.Information;
|
logLevel = LogEventLevel.Information;
|
||||||
|
|
||||||
@@ -407,9 +418,9 @@ namespace PepperDash.Core
|
|||||||
CrestronConsole.ConsoleCommandResponse("[Application {0}], Debug level set to {1}\r\n",
|
CrestronConsole.ConsoleCommandResponse("[Application {0}], Debug level set to {1}\r\n",
|
||||||
InitialParametersClass.ApplicationNumber, _consoleLoggingLevelSwitch.MinimumLevel);
|
InitialParametersClass.ApplicationNumber, _consoleLoggingLevelSwitch.MinimumLevel);
|
||||||
|
|
||||||
CrestronConsole.ConsoleCommandResponse($"Storing level {level}:{(int) level}");
|
CrestronConsole.ConsoleCommandResponse($"Storing level {level}:{(int)level}");
|
||||||
|
|
||||||
var err = CrestronDataStoreStatic.SetLocalIntValue(LevelStoreKey, (int) level);
|
var err = CrestronDataStoreStatic.SetLocalIntValue(LevelStoreKey, (int)level);
|
||||||
|
|
||||||
CrestronConsole.ConsoleCommandResponse($"Store result: {err}:{(int)level}");
|
CrestronConsole.ConsoleCommandResponse($"Store result: {err}:{(int)level}");
|
||||||
|
|
||||||
@@ -422,9 +433,9 @@ namespace PepperDash.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static void SetWebSocketMinimumDebugLevel(LogEventLevel level)
|
public static void SetWebSocketMinimumDebugLevel(LogEventLevel level)
|
||||||
{
|
{
|
||||||
_websocketLoggingLevelSwitch.MinimumLevel = level;
|
_websocketLoggingLevelSwitch.MinimumLevel = level;
|
||||||
|
|
||||||
var err = CrestronDataStoreStatic.SetLocalUintValue(WebSocketLevelStoreKey, (uint) level);
|
var err = CrestronDataStoreStatic.SetLocalUintValue(WebSocketLevelStoreKey, (uint)level);
|
||||||
|
|
||||||
if (err != CrestronDataStore.CDS_ERROR.CDS_SUCCESS)
|
if (err != CrestronDataStore.CDS_ERROR.CDS_SUCCESS)
|
||||||
LogMessage(LogEventLevel.Information, "Error saving websocket debug level setting: {erro}", err);
|
LogMessage(LogEventLevel.Information, "Error saving websocket debug level setting: {erro}", err);
|
||||||
@@ -491,83 +502,83 @@ namespace PepperDash.Core
|
|||||||
/// Callback for console command
|
/// Callback for console command
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="items"></param>
|
/// <param name="items"></param>
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// SetDebugFilterFromConsole method
|
/// SetDebugFilterFromConsole method
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void SetDebugFilterFromConsole(string items)
|
public static void SetDebugFilterFromConsole(string items)
|
||||||
{
|
{
|
||||||
var str = items.Trim();
|
var str = items.Trim();
|
||||||
if (str == "?")
|
if (str == "?")
|
||||||
{
|
{
|
||||||
CrestronConsole.ConsoleCommandResponse("Usage:\r APPDEBUGFILTER key1 key2 key3....\r " +
|
CrestronConsole.ConsoleCommandResponse("Usage:\r APPDEBUGFILTER key1 key2 key3....\r " +
|
||||||
"+all: at beginning puts filter into 'default include' mode\r" +
|
"+all: at beginning puts filter into 'default include' mode\r" +
|
||||||
" All keys that follow will be excluded from output.\r" +
|
" All keys that follow will be excluded from output.\r" +
|
||||||
"-all: at beginning puts filter into 'default exclude all' mode.\r" +
|
"-all: at beginning puts filter into 'default exclude all' mode.\r" +
|
||||||
" All keys that follow will be the only keys that are shown\r" +
|
" All keys that follow will be the only keys that are shown\r" +
|
||||||
"+nokey: Enables messages with no key (default)\r" +
|
"+nokey: Enables messages with no key (default)\r" +
|
||||||
"-nokey: Disables messages with no key.\r" +
|
"-nokey: Disables messages with no key.\r" +
|
||||||
"(nokey settings are independent of all other settings)");
|
"(nokey settings are independent of all other settings)");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var keys = Regex.Split(str, @"\s*");
|
var keys = Regex.Split(str, @"\s*");
|
||||||
foreach (var keyToken in keys)
|
foreach (var keyToken in keys)
|
||||||
{
|
{
|
||||||
var lkey = keyToken.ToLower();
|
var lkey = keyToken.ToLower();
|
||||||
if (lkey == "+all")
|
if (lkey == "+all")
|
||||||
{
|
{
|
||||||
IncludedExcludedKeys.Clear();
|
IncludedExcludedKeys.Clear();
|
||||||
_excludeAllMode = false;
|
_excludeAllMode = false;
|
||||||
}
|
}
|
||||||
else if (lkey == "-all")
|
else if (lkey == "-all")
|
||||||
{
|
{
|
||||||
IncludedExcludedKeys.Clear();
|
IncludedExcludedKeys.Clear();
|
||||||
_excludeAllMode = true;
|
_excludeAllMode = true;
|
||||||
}
|
}
|
||||||
//else if (lkey == "+nokey")
|
//else if (lkey == "+nokey")
|
||||||
//{
|
//{
|
||||||
// ExcludeNoKeyMessages = false;
|
// ExcludeNoKeyMessages = false;
|
||||||
//}
|
//}
|
||||||
//else if (lkey == "-nokey")
|
//else if (lkey == "-nokey")
|
||||||
//{
|
//{
|
||||||
// ExcludeNoKeyMessages = true;
|
// ExcludeNoKeyMessages = true;
|
||||||
//}
|
//}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string key;
|
string key;
|
||||||
if (lkey.StartsWith("-"))
|
if (lkey.StartsWith("-"))
|
||||||
{
|
{
|
||||||
key = lkey.Substring(1);
|
key = lkey.Substring(1);
|
||||||
// if in exclude all mode, we need to remove this from the inclusions
|
// if in exclude all mode, we need to remove this from the inclusions
|
||||||
if (_excludeAllMode)
|
if (_excludeAllMode)
|
||||||
{
|
{
|
||||||
if (IncludedExcludedKeys.ContainsKey(key))
|
if (IncludedExcludedKeys.ContainsKey(key))
|
||||||
IncludedExcludedKeys.Remove(key);
|
IncludedExcludedKeys.Remove(key);
|
||||||
}
|
}
|
||||||
// otherwise include all mode, add to the exclusions
|
// otherwise include all mode, add to the exclusions
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
IncludedExcludedKeys[key] = new object();
|
IncludedExcludedKeys[key] = new object();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (lkey.StartsWith("+"))
|
else if (lkey.StartsWith("+"))
|
||||||
{
|
{
|
||||||
key = lkey.Substring(1);
|
key = lkey.Substring(1);
|
||||||
// if in exclude all mode, we need to add this as inclusion
|
// if in exclude all mode, we need to add this as inclusion
|
||||||
if (_excludeAllMode)
|
if (_excludeAllMode)
|
||||||
{
|
{
|
||||||
|
|
||||||
IncludedExcludedKeys[key] = new object();
|
IncludedExcludedKeys[key] = new object();
|
||||||
}
|
}
|
||||||
// otherwise include all mode, remove this from exclusions
|
// otherwise include all mode, remove this from exclusions
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (IncludedExcludedKeys.ContainsKey(key))
|
if (IncludedExcludedKeys.ContainsKey(key))
|
||||||
IncludedExcludedKeys.Remove(key);
|
IncludedExcludedKeys.Remove(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -595,7 +606,7 @@ namespace PepperDash.Core
|
|||||||
public static object GetDeviceDebugSettingsForKey(string deviceKey)
|
public static object GetDeviceDebugSettingsForKey(string deviceKey)
|
||||||
{
|
{
|
||||||
return _contexts.GetDebugSettingsForKey(deviceKey);
|
return _contexts.GetDebugSettingsForKey(deviceKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sets the flag to prevent application starting on next boot
|
/// Sets the flag to prevent application starting on next boot
|
||||||
@@ -654,9 +665,15 @@ namespace PepperDash.Core
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Logs a message at the specified log level.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="level">Level to log at</param>
|
||||||
|
/// <param name="message">Message template</param>
|
||||||
|
/// <param name="args">Args to put into message template</param>
|
||||||
public static void LogMessage(LogEventLevel level, string message, params object[] args)
|
public static void LogMessage(LogEventLevel level, string message, params object[] args)
|
||||||
{
|
{
|
||||||
_logger.Write(level, message, args);
|
_logger.Write(level, message, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -692,7 +709,7 @@ namespace PepperDash.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static void LogVerbose(IKeyed keyed, string message, params object[] args)
|
public static void LogVerbose(IKeyed keyed, string message, params object[] args)
|
||||||
{
|
{
|
||||||
using(LogContext.PushProperty("Key", keyed?.Key))
|
using (LogContext.PushProperty("Key", keyed?.Key))
|
||||||
{
|
{
|
||||||
_logger.Write(LogEventLevel.Verbose, message, args);
|
_logger.Write(LogEventLevel.Verbose, message, args);
|
||||||
}
|
}
|
||||||
@@ -703,7 +720,7 @@ namespace PepperDash.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static void LogVerbose(Exception ex, IKeyed keyed, string message, params object[] args)
|
public static void LogVerbose(Exception ex, IKeyed keyed, string message, params object[] args)
|
||||||
{
|
{
|
||||||
using(LogContext.PushProperty("Key", keyed?.Key))
|
using (LogContext.PushProperty("Key", keyed?.Key))
|
||||||
{
|
{
|
||||||
_logger.Write(LogEventLevel.Verbose, ex, message, args);
|
_logger.Write(LogEventLevel.Verbose, ex, message, args);
|
||||||
}
|
}
|
||||||
@@ -722,7 +739,7 @@ namespace PepperDash.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static void LogVerbose(Exception ex, string message, params object[] args)
|
public static void LogVerbose(Exception ex, string message, params object[] args)
|
||||||
{
|
{
|
||||||
_logger.Write(LogEventLevel.Verbose, ex, null, message, args);
|
_logger.Write(LogEventLevel.Verbose, ex, message, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -798,7 +815,7 @@ namespace PepperDash.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static void LogInformation(Exception ex, string message, params object[] args)
|
public static void LogInformation(Exception ex, string message, params object[] args)
|
||||||
{
|
{
|
||||||
_logger.Write(LogEventLevel.Information, ex, null, message, args);
|
_logger.Write(LogEventLevel.Information, ex, message, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -836,7 +853,7 @@ namespace PepperDash.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static void LogWarning(Exception ex, string message, params object[] args)
|
public static void LogWarning(Exception ex, string message, params object[] args)
|
||||||
{
|
{
|
||||||
_logger.Write(LogEventLevel.Warning, ex, null, message, args);
|
_logger.Write(LogEventLevel.Warning, ex, message, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -874,7 +891,7 @@ namespace PepperDash.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static void LogError(Exception ex, string message, params object[] args)
|
public static void LogError(Exception ex, string message, params object[] args)
|
||||||
{
|
{
|
||||||
_logger.Write(LogEventLevel.Error, ex, null, message, args);
|
_logger.Write(LogEventLevel.Error, ex, message, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -912,7 +929,7 @@ namespace PepperDash.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static void LogFatal(Exception ex, string message, params object[] args)
|
public static void LogFatal(Exception ex, string message, params object[] args)
|
||||||
{
|
{
|
||||||
_logger.Write(LogEventLevel.Fatal, ex, null, message, args);
|
_logger.Write(LogEventLevel.Fatal, ex, message, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -923,7 +940,7 @@ namespace PepperDash.Core
|
|||||||
if (!_logLevels.ContainsKey(level)) return;
|
if (!_logLevels.ContainsKey(level)) return;
|
||||||
|
|
||||||
var logLevel = _logLevels[level];
|
var logLevel = _logLevels[level];
|
||||||
|
|
||||||
LogMessage(logLevel, format, items);
|
LogMessage(logLevel, format, items);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -978,7 +995,7 @@ namespace PepperDash.Core
|
|||||||
[Obsolete("Use LogMessage methods, Will be removed in 2.2.0 and later versions")]
|
[Obsolete("Use LogMessage methods, Will be removed in 2.2.0 and later versions")]
|
||||||
public static void Console(uint level, IKeyed dev, ErrorLogLevel errorLogLevel,
|
public static void Console(uint level, IKeyed dev, ErrorLogLevel errorLogLevel,
|
||||||
string format, params object[] items)
|
string format, params object[] items)
|
||||||
{
|
{
|
||||||
LogMessage(level, dev, format, items);
|
LogMessage(level, dev, format, items);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1122,7 +1139,7 @@ namespace PepperDash.Core
|
|||||||
return string.Format(@"\user\debugSettings\program{0}", InitialParametersClass.ApplicationNumber);
|
return string.Format(@"\user\debugSettings\program{0}", InitialParametersClass.ApplicationNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
return string.Format("{0}{1}user{1}debugSettings{1}{2}.json",Directory.GetApplicationRootDirectory(), Path.DirectorySeparatorChar, InitialParametersClass.RoomId);
|
return string.Format("{0}{1}user{1}debugSettings{1}{2}.json", Directory.GetApplicationRootDirectory(), Path.DirectorySeparatorChar, InitialParametersClass.RoomId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -1133,15 +1150,15 @@ namespace PepperDash.Core
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Error
|
/// Error
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Error,
|
Error,
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Warning
|
/// Warning
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Warning,
|
Warning,
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Notice
|
/// Notice
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Notice,
|
Notice,
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// None
|
/// None
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user