diff --git a/Pepperdash Core/CLZ Builds/PepperDash_Core.clz b/Pepperdash Core/CLZ Builds/PepperDash_Core.clz index b6c27f1..f485ab8 100644 Binary files a/Pepperdash Core/CLZ Builds/PepperDash_Core.clz and b/Pepperdash Core/CLZ Builds/PepperDash_Core.clz differ diff --git a/Pepperdash Core/CLZ Builds/PepperDash_Core.dll b/Pepperdash Core/CLZ Builds/PepperDash_Core.dll index 8f72cb7..aeb145c 100644 Binary files a/Pepperdash Core/CLZ Builds/PepperDash_Core.dll and b/Pepperdash Core/CLZ Builds/PepperDash_Core.dll differ diff --git a/Pepperdash Core/Pepperdash Core/Logging/Debug.cs b/Pepperdash Core/Pepperdash Core/Logging/Debug.cs index fe64a0d..496a02b 100644 --- a/Pepperdash Core/Pepperdash Core/Logging/Debug.cs +++ b/Pepperdash Core/Pepperdash Core/Logging/Debug.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using System.Text.RegularExpressions; using Crestron.SimplSharp; using Crestron.SimplSharp.CrestronLogger; using Crestron.SimplSharp.CrestronIO; @@ -32,8 +33,20 @@ namespace PepperDash.Core static CTimer SaveTimer; + /// + /// When true, the IncludedExcludedKeys dict will contain keys to include. + /// When false (default), IncludedExcludedKeys will contain keys to exclude. + /// + static bool ExcludeAllMode; + + static bool ExcludeNoKeyMessages; + + static Dictionary IncludedExcludedKeys; + static Debug() { + IncludedExcludedKeys = new Dictionary(); + //CrestronDataStoreStatic.InitCrestronDataStore(); if (CrestronEnvironment.RuntimeEnvironment == eRuntimeEnvironment.SimplSharpPro) { @@ -47,6 +60,8 @@ namespace PepperDash.Core CrestronConsole.AddNewConsoleCommand(s => CrestronLogger.Clear(false), "appdebugclear", "appdebugclear:P Clears the current custom log", ConsoleAccessLevelEnum.AccessOperator); + CrestronConsole.AddNewConsoleCommand(SetDebugFilterFromConsole, "appdebugfilter", + "appdebugfilter [params]", ConsoleAccessLevelEnum.AccessOperator); } CrestronEnvironment.ProgramStatusEventHandler += CrestronEnvironment_ProgramStatusEventHandler; @@ -97,6 +112,82 @@ namespace PepperDash.Core } } + public static void SetDebugFilterFromConsole(string items) + { + var str = items.Trim(); + if (str == "?") + { + CrestronConsole.ConsoleCommandResponse("Usage:\r APPDEBUGFILTER key1 key2 key3....\r " + + "+all: at beginning puts filter into 'default include' mode\r" + + " All keys that follow will be excluded from output.\r" + + "-all: at beginning puts filter into 'default excluse all' mode.\r" + + " All keys that follow will be the only keys that are shown\r" + + "+nokey: Enables messages with no key (default)\r" + + "-nokey: Disables messages with no key.\r" + + "(nokey settings are independent of all other settings)"); + return; + } + var keys = Regex.Split(str, @"\s*"); + foreach (var keyToken in keys) + { + var lkey = keyToken.ToLower(); + if (lkey == "+all") + { + IncludedExcludedKeys.Clear(); + ExcludeAllMode = false; + } + else if (lkey == "-all") + { + IncludedExcludedKeys.Clear(); + ExcludeAllMode = true; + } + else if (lkey == "+nokey") + { + ExcludeNoKeyMessages = false; + } + else if (lkey == "-nokey") + { + ExcludeNoKeyMessages = true; + } + else + { + string key = null; ; + if (lkey.StartsWith("-")) + { + key = lkey.Substring(1); + // if in exclude all mode, we need to remove this from the inclusions + if (ExcludeAllMode) + { + if (IncludedExcludedKeys.ContainsKey(key)) + IncludedExcludedKeys.Remove(key); + } + // otherwise include all mode, add to the exclusions + else + { + IncludedExcludedKeys[key] = new object(); + } + } + else if (lkey.StartsWith("+")) + { + key = lkey.Substring(1); + // if in exclude all mode, we need to add this as inclusion + if (ExcludeAllMode) + { + + IncludedExcludedKeys[key] = new object(); + } + // otherwise include all mode, remove this from exclusions + else + { + if (IncludedExcludedKeys.ContainsKey(key)) + IncludedExcludedKeys.Remove(key); + } + } + } + } + } + + /// /// Sets the debug level ///