Show Menu
Cheatography

ArduinoLog Cheat Sheet by

Cheatsheet for ArduinoLog library

Variables

%s
string (char*)
%S
string from flash memory (char[] PROGMEM)
%c
single character
%C
signel character (hex if not printable)
%d
integer
%l
long
%u
unsigned long
%x
hexade­cimal
%X
hexade­cimal (0x prefix) and leading zeros
%b
binary number
%B
binary number (0b prefix)
%t
boolean 't' or 'f'
%T
boolean 'true' or 'false'
%D, %F
double
%p
printable object
Example: Log.no­tic­e("T­emp­era­ture: %D", temp_c);
 

Initia­liz­ation

Serial.begin(9600);
    
// Initialize with log level and log output. 
Log.begin   (LOG_giLEVEL_VERBOSE, &Serial);

Log leveles

LOG_LE­VEL­_SILENT
no output
LOG_LE­VEL­_FATAL
fatal errors
LOG_LE­VEL­_ERROR
all errors
LOG_LE­VEL­_WA­RNING
errors and warnings
LOG_LE­VEL­_NOTICE
errors, warnings and notices
LOG_LE­VEL­_TRACE
errors, warnings, notices and traces
LOG_LE­VEL­_VE­RBOSE
all
 

Disable library

Uncomment #define DISABL­E_L­OGGING in Logging.h
This may signif­icantly reduce your project size.

Custom logging format

Log.setPrefix(printPrefix);
Log.setSuffix(printSuffix);
Log.notice("Message to be logged");

void printPrefix(Print* _logOutput, int logLevel) {
    _logOutput->print("00:47:51.432 ");
}

void printSuffix(Print* _logOutput, int logLevel) {
     _logOutput->print(".");
}
Result:
00:47:­51.432 Message to be logged.
 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          ArduinoNetworks - Arduino Cheat Sheet
          arduino Cheat Sheet