Skip to content

function to print current debugLevel as string #7

Closed
@MattStarfield

Description

@MattStarfield

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
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions