Skip to content

1.0.10

Latest

Choose a tag to compare

@PiFou86 PiFou86 released this 06 Sep 20:43

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 inside if/else statements.
  • Prevented disabled macro arguments from being evaluated.
  • Avoided unnecessary String construction for filtered const 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_METHOD
  • LOGGER_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, and VERBOSE.
  • The default level remains INFO.
  • The global Logger instance remains available.
  • Existing print(), println(), level methods, and overloads remain unchanged.
  • Passing false as writePrefix removes both the timestamp and the level label.
  • The Stream passed to Logger.begin() remains non-owning.

Tests

The native test suite covers:

  • initialization with and without a Stream;
  • the default and configurable log levels;
  • String and const char* overloads;
  • filtered and active messages;
  • prefixed and unprefixed output;
  • print() and println();
  • all four trace macros;
  • macro use inside real if/else statements;
  • absence of evaluation for filtered expressions;
  • single evaluation for enabled expressions;
  • absence of unnecessary String construction;
  • 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.10

Utilify 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!