A basic Arduino library to help with logging through a Stream
like Serial
. The added beneficts of this library are:
- You can deactivate all logging with one line of code.
- You can print up to 9 values with the same function instead of calling multiple
print()
.
Add to your global space:
#include <MicroLog.h>
By default, MicroLog will use Serial
. You can change the Stream
(to Serial1 for example) with :
#define MICRO_LOG_STREAM Serial1
In setup()
begin the Stream (to a baud of 115200) with :
LOG_BEGIN(115200)
You can then log to the stream with LOG()
like this :
// THIS WILL LOG SOMETHING LIKE : "Millis : 3294"
LOG("Millis :", millis());
You can have up to 9 arguments with LOG()
:
// THIS WILL LOG SOMETHING LIKE : "State of pin 3 is 0 and state of pon 2 is 1"
LOG("State of pin", 3 , "is" , digitalRead(3), "and", "state of pin", 2 , "is" , digitalRead(2));
By default, the separator is a space " ", but this can be changed to anything by adding before #include <MicroLog.h>
:
#define LOG_SEPARATOR "|"
#include <MicroLog.h>
To deactive the logging, add before #include <MicroLog.h>
:
#define LOG_DEACTIVATE
#include <MicroLog.h>