Description
At times, it can be helpful to print the current debug level to the serial monitor as a string. I've implemented this in my own code, but it could be helpful to include in the library to be accessible to all...
// Enum to String Inline Function
//----------------------------------------------------------------------------
// * Translates enum value to a printable string
// * enums are mapped to strings by order in list
// * use static inline keywords to allow function definition in .h file
static inline char* debugLevelToString(int debugLevel)
{
char* str[] =
{
"DBG_NONE",
"DBG_ERROR",
"DBG_WARNING",
"DBG_INFO",
"DBG_DEBUG",
"DBG_VERBOSE"
};
return str[debugLevel+1]; // DBG_NONE assigned to -1, so add 1 for correct output string
}