Merge branch 'main' into current-sources

This commit is contained in:
Andrew Welker
2025-07-31 13:27:43 -05:00

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.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,6 +97,9 @@ 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>
@@ -106,14 +115,15 @@ namespace PepperDash.Core
/// </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()
@@ -272,7 +282,8 @@ namespace PepperDash.Core
} }
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;
@@ -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) public static void LogMessage(LogEventLevel level, string message, params object[] args)
{ {
_logger.Write(level, message, args); _logger.Write(level, 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