Updated Debugging (markdown)

Neil Dorin
2020-02-11 18:18:47 -07:00
parent 83b1cae06f
commit fa6524234a

@@ -29,7 +29,31 @@
## How to use the PepperDash.Core Debug Class ## How to use the PepperDash.Core Debug Class
The majority of interaction is done via console, preferably via an SSH session through Crestron Toolbox, PuTTy or any other suitable application. The majority of interaction is done via console, preferably via an SSH session through Crestron Toolbox, PuTTy or any other suitable application.
In code, the most useful method is `Debug.Console()` which has several overloads. All variations take an integer value for the level (0-2) as the first argument. Level 0 will ALWAYS print. Level 1 is for typical debug messages and level 2 is for verbose debugging. In cases where the overloads that accept a `Debug.ErrorLogLevel` parameter are used, the message will ALWAYS be logged, but will only print to console if the current debug level is the same or higher than the level set in the `Debug.Console()` statement.
All statements printed to console are prefixed by a timestamp which can be greatly helpful in debugging order of operations.
``` csharp
// The most basic use, sets the level (0) and the message to print.
Debug.Console(0, "Hello World");
// prints: [timestamp]App 1:Hello World
// The string parameter has a built in string.Format() that takes params object[] items
string world = "World";
Debug.Console(0, "Hello {0}", world);
// prints: [timestamp]App 1:Hello World
// This overload takes an IKeyed as the second parameter and the resulting statement will
// print the Key of the device in console to help identify the class instance the message
// originated from
Debug.Console(0, this, "Hello World);
// prints: [timestamp]App 1:[deviceKey]Hello World
// Each of the above overloads has a corresponding variant that takes an argument to indicate
// the level of error to log the message at as well as printing to console
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Hello World");
// prints: [timestamp]App 1:Hello World
```
## Console Commands ## Console Commands
### Appdebug:[slot] [0-2] ### Appdebug:[slot] [0-2]