mirror of
https://github.com/PepperDash/PepperDashCore.git
synced 2026-02-16 05:04:48 +00:00
fix: debug all devices when devices array is empty
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Crestron.SimplSharp;
|
using Crestron.SimplSharp;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
@@ -56,10 +57,21 @@ namespace PepperDash.Core.Logging
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (@event.Properties.TryGetValue("Key", out var value) &&
|
if (@event.Properties.TryGetValue("Key", out var value) && value is ScalarValue { Value: string rawValue }
|
||||||
value is ScalarValue { Value: string rawValue })
|
&& DebugContext.TryGetDataForKey(Debug.ConsoleLevelStoreKey, out var data)
|
||||||
|
&& data.Devices != null)
|
||||||
{
|
{
|
||||||
return DebugContext.DeviceExistsInContext(Debug.ConsoleLevelStoreKey, rawValue);
|
if (data.Devices.Length == 0)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.Devices.Any(d => d == rawValue))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -48,15 +48,12 @@ namespace PepperDash.Core.Logging
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DebugContextData GetDataForKey(string key, LogEventLevel defaultLevel) =>
|
public static bool TryGetDataForKey(string key, out DebugContextData data) =>
|
||||||
|
CurrentData.TryGetValue(key, out var data);
|
||||||
|
|
||||||
|
public static DebugContextData GetOrCreateDataForKey(string key, LogEventLevel defaultLevel) =>
|
||||||
CurrentData.TryGetValue(key, out var data) ? data : new DebugContextData(defaultLevel);
|
CurrentData.TryGetValue(key, out var data) ? data : new DebugContextData(defaultLevel);
|
||||||
|
|
||||||
public static bool DeviceExistsInContext(string contextKey, string deviceKey) =>
|
|
||||||
CurrentData.TryGetValue(contextKey, out var data) switch
|
|
||||||
{
|
|
||||||
true when data.Devices != null => data.Devices.Any(key => string.Equals(key, deviceKey, StringComparison.OrdinalIgnoreCase)),
|
|
||||||
_ => false
|
|
||||||
};
|
|
||||||
|
|
||||||
public static void SetDataForKey(string key, LogEventLevel defaultLevel, string[] devices = null)
|
public static void SetDataForKey(string key, LogEventLevel defaultLevel, string[] devices = null)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user