https://github.com/vovagorodok/arduinostreamlogger
Advanced logger with log level changing
https://github.com/vovagorodok/arduinostreamlogger
arduino logger logging platformio
Last synced: 2 months ago
JSON representation
Advanced logger with log level changing
- Host: GitHub
- URL: https://github.com/vovagorodok/arduinostreamlogger
- Owner: vovagorodok
- License: mit
- Created: 2022-08-27T16:07:17.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2026-04-15T00:02:14.000Z (2 months ago)
- Last Synced: 2026-04-15T02:02:38.834Z (2 months ago)
- Topics: arduino, logger, logging, platformio
- Language: C++
- Homepage:
- Size: 85 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Arduino Stream Logger
Library opens posibility of logging by using ostream.
When log level is disabled (by adding `-D LOG_LEVEL_DISABLED` or removing `-D LOG_LEVEL_..`) then all strings, operators calls, etc. will be optimized/removed from binary.
## Using
Use as follows:
```
#include
...
LOG_DEBUG << "debug";
LOG_INFO << "info";
LOG_WARNING << "warning";
LOG_ERROR << "error";
```
## Optimization aspects
Compiler will not optimize function calls.
For example, in case of `LOG_LEVEL_INFO` and debug with function call:
```
LOG_DEBUG << foo();
```
Compiler optimize only logging, but `foo()` will be called.
Following macro will help to optimize all:
```
LOG_CALL_DEBUG(<< foo());
```
## Additional format options
Disable prefix:
```
build_flags =
-D LOG_FORMAT_WITHOUT_PREFIX
```
Custom separator:
```
build_flags =
-D LOG_FORMAT_SEPARATOR='"\\\\"'
```
Default separator is `": "`.
## Configuration
Library require c++17 or newer.
For PlatformIO. Add `LOG_LEVEL_INFO` or `LOG_LVL_INFO` to `platformio.ini`:
```
build_flags =
-std=c++17
-std=gnu++17
-D LOG_LEVEL_INFO
build_unflags =
-std=gnu++11
```
For Arduino IDE. At boards package installation folder create `platform.local.txt`:
```
compiler.cpp.extra_flags=-std=c++17 -D LOG_LEVEL_INFO
```