Repository navigation
UtilifyLogger 1.0.10
UtilifyLogger 1.0.10 improves macro safety, disabled-message performance, long-duration timestamps, testing, and documentation without changing the public API.
Highlights
- Made all
LOGGER_*macros safe insideif/elsestatements. - Prevented disabled macro arguments from being evaluated.
- Avoided unnecessary
Stringconstruction for filteredconst char*messages. - Added an explicit day prefix after 24 hours.
- Added comprehensive native unit tests.
- Added GitHub Actions continuous integration.
- Improved PlatformIO package metadata.
Safer trace macros
The following macros now use the conventional do { ... } while (false) structure:
LOGGER_BEGIN_METHODLOGGER_TRACE(message)LOGGER_VAR(variable)LOGGER_END_METHOD
They can safely be used in control-flow statements:
if (condition)
LOGGER_TRACE(F("Condition is true"));
else
handleAlternative();The macros no longer contain an internal trailing semicolon.
Filtered message performance
When the current log level hides a VERBOSE trace macro:
- its argument is not evaluated;
- no temporary message is constructed;
- no dynamic string allocation is performed;
- expressions with side effects are not executed.
An enabled macro evaluates its argument exactly once.
The const char* overloads also check the current level before constructing an Arduino String.
Timestamp improvements
Timestamps remain unchanged during the first 24 hours:
00:00:00.000
23:59:59.999
Starting at 24 hours, the number of complete days is included:
1d 00:00:00.000
2d 03:04:05.006
On platforms where unsigned long is 32 bits, the timestamp restarts when Arduino's millis() counter wraps after approximately 49.7 days.
Compatibility note: Log parsers should accept the new day prefix for timestamps at or above 24 hours.
Existing behavior preserved
- Supported levels remain
ERROR,WARNING,INFO, andVERBOSE. - The default level remains
INFO. - The global
Loggerinstance remains available. - Existing
print(),println(), level methods, and overloads remain unchanged. - Passing
falseaswritePrefixremoves both the timestamp and the level label. - The
Streampassed toLogger.begin()remains non-owning.
Tests
The native test suite covers:
- initialization with and without a
Stream; - the default and configurable log levels;
Stringandconst char*overloads;- filtered and active messages;
- prefixed and unprefixed output;
print()andprintln();- all four trace macros;
- macro use inside real
if/elsestatements; - absence of evaluation for filtered expressions;
- single evaluation for enabled expressions;
- absence of unnecessary
Stringconstruction; - timestamps below and above 24 hours.
The Uno R3 and ESP32 native profiles each execute 24 tests without requiring a connected board.
Supported platforms
- Arduino Uno R3
- ESP32 using the Arduino framework
Installation
Available from the PlatformIO Registry:
lib_deps =
sirdrako/UtilifyLogger@^1.0.10Utilify is installed automatically as a declared dependency.
Concurrency and lifetime
Logger.begin() stores a non-owning pointer to the supplied Stream. The stream must remain alive for as long as the logger can use it.
UtilifyLogger does not synchronize concurrent writes. Applications sharing the global logger between several ESP32 tasks must serialize access to the output stream.
Compatibility
No existing public constructor, method, macro, log level, or global object has been removed or renamed.
The only intentional output-format change is the day prefix added after 24 hours.
Thank you for using UtilifyLogger!