Log
Xi::Log is a unified, cross-platform diagnostic logging utility. It is designed to provide identical macro-like simplicity across completely disparate hardware targets, routing output seamlessly to the hardware's native console.
Architectural Overview: Hardware Abstraction
On an ESP32 or Arduino, developers print diagnostics using Serial.println(). On a Linux server or desktop environment, developers use std::cerr or std::cout.
Xi::Log completely abstracts this difference. You write your business logic once using Xi::println(), and the framework automatically resolves the output:
On Microcontrollers (
ARDUINOdefined): Output is piped directly to the UART hardwareSerial.On Linux/OSX/Windows (
ARDUINOundefined): Output is piped to standard error (std::cerr), keeping standard output (std::cout) clean for your application's binary pipeline.
π Complete API Reference
1. Global Shortcuts
You do not need to instantiate the Log class. Xi provides global namespace functions for immediate, ergonomic usage that mimic standard output syntax.
Xi::print(const T &msg)Prints the message without a trailing newline. Safely formats any primitive orXi::String.Xi::println()Emits a bare newline character.Xi::println(const T &msg)Prints the message followed by a newline.
2. Log Leveling
Instead of commenting out print statements when moving from debug to release, Xi::Log provides dedicated semantic logging levels.
Xi::verbose(const T &msg)Xi::info(const T &msg)Xi::warn(const T &msg)Xi::error(const T &msg)Xi::critical(const T &msg)
Setting the Global Level Threshold: You can globally silence logs below a certain importance using the Singleton configuration.
Xi::Log::getInstance().setLevel(Xi::LogLevel l)Levels include:Verbose,Info,Warning,Error,Critical, andNone. Any log emitted below the active threshold is completely ignored.
π» Example: Cross-Platform Logging
Last updated