Pretty Debug

A minimal debug library written in C

Posted by Shadly on May 12, 2018

PrettyDebug

A lightweight debug library written in C/C++. It is designed especially for embedded systems keeping in mind the limitation and capabilities of the platform.

  • Low memory usage
  • Supports a wide range of compilers and processor architectures
  • Arduino compatible
  • ESP32 & ESP8266 supported
  • Color debug output
  • Very easy to use

How to use

  • Attach Debug Stream :
    1
    
    ATTACH_DEBUG_STREAM(&Serial);
    
  • Print Green OK Message :
    1
    
    DEBUG_OK("An Example OK Message From %s, "PrettyDebug");
    
  • Print Red ERROR Message :
    1
    
    DEBUG_ERROR("An Example ERROR Message From %s, "PrettyDebug");
    
  • Print Red ERROR Message :
    1
    
    DEBUG_ERROR("An Example ERROR Message From %s, "PrettyDebug");
    
  • Print Cyan ALERT Message :
    1
    
    DEBUG_ALERT("An Example ALERT Message From %s, "PrettyDebug");
    
  • Print Yellow WARNING Message :
    1
    
    DEBUG_WARNING("An Example WARNING Message From %s, "PrettyDebug");
    
  • Print Variable with Variable Name :
    1
    
    DEBUG_VARIABLE("%d", Sample_Value);
    
  • Print Array with Name :
    1
    
    DEBUG_ARRAY(Sample_Array, 16, "%02X");
    

Print Current Location in Code :

1
  DEBUG_TRACE();

Arduino Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
  #include "PrettyDebug.h"

  int Sample_Variable = 123;
  int Sample_Array[] = {1, 2, 3, 4, 5};

  void setup(){
      Serial.begin(115200);
      ATTACH_DEBUG_STREAM(&Serial);

      DEBUG_OK("Pretty Debug Example Sketch");
      DEBUG_TRACE();

      DEBUG_OK("An Example OK Message From %s, "PrettyDebug");
      DEBUG_ERROR("An Example ERROR Message From %s, "PrettyDebug");
      DEBUG_ERROR("An Example ERROR Message From %s, "PrettyDebug");
      DEBUG_ALERT("An Example ALERT Message From %s, "PrettyDebug");
      DEBUG_WARNING("An Example WARNING Message From %s, "PrettyDebug");
      DEBUG_VALUE(Sample_Value, "%d");
      DEBUG_ARRAY(Sample_Array, 16, "%02X");
  }

  void loop(){

  }

Sample Output

Sample Output