Teensy Logging to Serial

Frank B

Senior Member
I've created a little logging tool, somewhat similar to the one ESP32 has. I wrote it for myself, but I think it can be userful for others, too - so here it is:

https://github.com/FrankBoesing/Teensy_Logger

After installation, you can set the log level via the Arduino-Menu:

2020-11-30 20_50_30-Suche.png

Here is a short example:
Code:
#include <teensy_logger.h>

void setup() {
  Serial.printf("Log Level: %d\n", LOG_LEVEL);
}

void loop() {  
  delay(1002);
  Serial.println("===");
  LOGE("%s", "Error");
  LOGW("%s", "This is a warning :)");
  LOGI("%s", "Information!");
  LOGD("%s %d %s", "Debug", __LINE__, __FILE__);
  LOGV("%s", "Verbose");  
}

So, for development, you can insert a lot of debug information to your program, and just switch it on and off via the menu.
The syntax is similar to printf, (it uses printf) so you can use all printf format-strings.

There are a few additional, optional macros (set before the #include):

#define LOGDEVICE Serial // <- device to log to
#define LOGTIMESTAMP // print a Timestamp?
#define LOGPRINTLEVEL // add inofrmation about loglevel of LOGx Macro

Output with timestamp and loglevel:
Code:
00:00:40.201 [WARNING]  This is a warning :)
 
Last edited:
I've created a little logging tool, somewhat similar to the one ESP32 has. I wrote it for myself, but I think it can be userful for others, too - so here it is.

Looks useful, maybe I'm just blind but where do I find it :)

Edit: OK, I'm blind....
 
I've seen debug log messages like "value too high", which leaves me lost as to what it means and how to fix it.

For some use cases, consider using something like:

LOGD("%s %d %s", "Debug", __LINE__, __FILE__);
 
Back
Top