diff --git a/Pepperdash Core/Pepperdash Core/CoreInterfaces.cs b/Pepperdash Core/Pepperdash Core/CoreInterfaces.cs
index 3a5df42..2a46e2a 100644
--- a/Pepperdash Core/Pepperdash Core/CoreInterfaces.cs
+++ b/Pepperdash Core/Pepperdash Core/CoreInterfaces.cs
@@ -18,7 +18,8 @@ namespace PepperDash.Core
}
///
- /// Named Keyed device interface. Forces the devie to have a Unique Key and a name.
+ /// Named Keyed device interface.
+ /// Forces the device to have a Unique Key and a name.
///
public interface IKeyName : IKeyed
{
diff --git a/Pepperdash Core/Pepperdash Core/Device.cs b/Pepperdash Core/Pepperdash Core/Device.cs
index 62dc6b1..fe209f8 100644
--- a/Pepperdash Core/Pepperdash Core/Device.cs
+++ b/Pepperdash Core/Pepperdash Core/Device.cs
@@ -6,7 +6,8 @@ namespace PepperDash.Core
{
//*********************************************************************************************************
///
- /// The core event and status-bearing class that most if not all device and connectors can derive from.
+ /// The core event and status-bearing class that most if not all device
+ /// and connectors can derive from.
///
public class Device : IKeyName
{
diff --git a/Pepperdash Core/Pepperdash Core/Logging/Debug.cs b/Pepperdash Core/Pepperdash Core/Logging/Debug.cs
index 5d245d2..539f635 100644
--- a/Pepperdash Core/Pepperdash Core/Logging/Debug.cs
+++ b/Pepperdash Core/Pepperdash Core/Logging/Debug.cs
@@ -34,10 +34,20 @@ namespace PepperDash.Core
static int SaveTimeoutMs = 30000;
+ ///
+ /// Default debug timeout (30 min)
+ ///
+ static long DebugTimoutMs = 1800000;
+
public static string PepperDashCoreVersion { get; private set; }
static CTimer SaveTimer;
+ ///
+ /// Resets the debug level to 0 when the timer expires
+ ///
+ static CTimer DebugTimer;
+
///
/// When true, the IncludedExcludedKeys dict will contain keys to include.
/// When false (default), IncludedExcludedKeys will contain keys to exclude.
@@ -71,7 +81,7 @@ namespace PepperDash.Core
"donotloadonnextboot:P [true/false]: Should the application load on next boot", ConsoleAccessLevelEnum.AccessOperator);
CrestronConsole.AddNewConsoleCommand(SetDebugFromConsole, "appdebug",
- "appdebug:P [0-2]: Sets the application's console debug message level",
+ "appdebug:P [level 0-2] [(min)]: Set the console debug message level",
ConsoleAccessLevelEnum.AccessOperator);
CrestronConsole.AddNewConsoleCommand(ShowDebugLog, "appdebuglog",
"appdebuglog:P [all] Use \"all\" for full log.",
@@ -130,24 +140,49 @@ namespace PepperDash.Core
}
///
- /// Callback for console command
+ /// Callback for console command. Starts the debug Timer
///
///
public static void SetDebugFromConsole(string levelString)
{
try
{
+ var args = levelString.Split(' ');
+
+ var level = Convert.ToInt32(args[0]);
+ var timeoutMs = DebugTimoutMs;
+
+ if(args.Length > 1)
+ {
+ timeoutMs = Convert.ToInt32(args[1]) * 60000;
+ }
+
+
+ // Only start the timer if setting to level 1 or 2
+ if (level > 0 && level <= 2)
+ {
+ if (DebugTimer != null)
+ {
+ DebugTimer = new CTimer((o) => SetDebugLevel(0), timeoutMs);
+ }
+ else
+ {
+ DebugTimer.Reset(timeoutMs);
+ }
+ }
+
+
if (string.IsNullOrEmpty(levelString.Trim()))
{
CrestronConsole.PrintLine("AppDebug level = {0}", Level);
return;
}
- SetDebugLevel(Convert.ToInt32(levelString));
+ SetDebugLevel(level, timeoutMs);
}
catch
{
- CrestronConsole.PrintLine("Usage: appdebug:P [0-2]");
+ CrestronConsole.PrintLine("Usage: appdebug:P [level: 0-2] [(timeout in minutes: 0-480)]");
}
}
@@ -261,6 +296,13 @@ namespace PepperDash.Core
{
if (level <= 2)
{
+ if (level == 0)
+ {
+ DebugTimer.Stop();
+ DebugTimer.Dispose();
+ DebugTimer = null;
+ }
+
Level = level;
Contexts.GetOrCreateItem("DEFAULT").Level = level;
SaveMemoryOnTimeout();
@@ -274,6 +316,17 @@ namespace PepperDash.Core
}
}
+ public static void SetDebugLevel(int level, long timeoutMs)
+ {
+ if (level <= 2 && level > 0)
+ {
+ CrestronConsole.PrintLine("[Application {0}], Debug timer will expire in {1} minutes",
+ InitialParametersClass.ApplicationNumber, timeoutMs / 60000);
+ }
+
+ SetDebugLevel(level);
+ }
+
///
/// sets the settings for a device or creates a new entry
///