Merge pull request #1303 from PepperDash/debug-fixes

fix: use correct overload for logging at levels
This commit is contained in:
Andrew Welker
2025-07-31 13:03:14 -05:00
committed by GitHub

View File

@@ -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.CrestronIO;
using Crestron.SimplSharp.CrestronLogger;
@@ -11,10 +15,6 @@ using Serilog.Events;
using Serilog.Formatting.Compact;
using Serilog.Formatting.Json;
using Serilog.Templates;
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Text.RegularExpressions;
namespace PepperDash.Core
{
@@ -48,6 +48,9 @@ namespace PepperDash.Core
private static readonly LoggingLevelSwitch _fileLevelSwitch;
/// <summary>
/// Gets the minimum log level for the websocket sink.
/// </summary>
public static LogEventLevel WebsocketMinimumLogLevel
{
get { return _websocketLoggingLevelSwitch.MinimumLevel; }
@@ -55,6 +58,9 @@ namespace PepperDash.Core
private static readonly DebugWebsocketSink _websocketSink;
/// <summary>
/// Gets the websocket sink for debug logging.
/// </summary>
public static DebugWebsocketSink WebsocketSink
{
get { return _websocketSink; }
@@ -91,6 +97,9 @@ namespace PepperDash.Core
private const int SaveTimeoutMs = 30000;
/// <summary>
/// Indicates whether the system is running on an appliance.
/// </summary>
public static bool IsRunningOnAppliance = CrestronEnvironment.DevicePlatform == eDevicePlatform.Appliance;
/// <summary>
@@ -106,14 +115,15 @@ namespace PepperDash.Core
/// </summary>
private static bool _excludeAllMode;
//static bool ExcludeNoKeyMessages;
private static readonly Dictionary<string, object> IncludedExcludedKeys;
private static readonly LoggerConfiguration _defaultLoggerConfiguration;
private static LoggerConfiguration _loggerConfiguration;
/// <summary>
/// Gets the logger configuration for the debug logging.
/// </summary>
public static LoggerConfiguration LoggerConfiguration => _loggerConfiguration;
static Debug()
@@ -272,7 +282,8 @@ namespace PepperDash.Core
}
return (LogEventLevel)logLevel;
} catch (Exception ex)
}
catch (Exception ex)
{
CrestronConsole.PrintLine($"Exception retrieving log level for {levelStoreKey}: {ex.Message}");
return LogEventLevel.Information;
@@ -654,6 +665,12 @@ 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)
{
_logger.Write(level, message, args);
@@ -722,7 +739,7 @@ namespace PepperDash.Core
/// </summary>
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>
@@ -798,7 +815,7 @@ namespace PepperDash.Core
/// </summary>
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>
@@ -836,7 +853,7 @@ namespace PepperDash.Core
/// </summary>
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>
@@ -874,7 +891,7 @@ namespace PepperDash.Core
/// </summary>
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>
@@ -912,7 +929,7 @@ namespace PepperDash.Core
/// </summary>
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