Diagnostic logging to UART and/or Ethernet ports.
Log objects are used for diagnostic logging, with a few simple formatting options. They are intended for simple debugging while being much lighter-weight than printf() or sprintf(). Log messages can be conveyed to a console, a UART, or even a network interface. Each Log message carries a priority code to allow filtering.
The objects in this file are used to generate log messages. For receiving messages,
- See also
- log_cbor.h or the "test/log_viewer" tool.
Each Log object formats and emits a single human-readable message. The Log object is ephemeral, with chaining for readable syntax. Additional "write" calls append information to the message; the final message is sent when the Log object falls out of scope.
Each of the three examples below produces the same formatted message:
void example1(u8 errcode) {
Log(satcat5::log::WARNING,
"Oh noooo").
write(errcode);
}
void example2(u8 errcode) {
Log(satcat5::log::WARNING).
write(
"Oh noooo").
write(errcode);
}
void example3(u8 errcode) {
Log log(satcat5::log::WARNING);
log.write("Oh noooo");
log.write(errcode);
}
The Log class creates and formats one log message.
Log & write(const char *str)
Formatting methods for various data types.
When the Log object falls out of scope, the message contents are written to every object that defines the log::EventHandler interface.
Definition in file log.h.
|
|
constexpr s8 | LOG_DEBUG = satcat5::log::DEBUG |
| |
|
constexpr s8 | LOG_INFO = satcat5::log::INFO |
| |
|
constexpr s8 | LOG_WARNING = satcat5::log::WARNING |
| |
|
constexpr s8 | LOG_ERROR = satcat5::log::ERROR |
| |
|
constexpr s8 | LOG_CRITICAL = satcat5::log::CRITICAL |
| |
|
| constexpr s8 | satcat5::log::DEBUG = -20 |
| | Define basic priority codes for log messages. More...
|
| |
| constexpr s8 | satcat5::log::INFO = -10 |
| | Define basic priority codes for log messages. More...
|
| |
| constexpr s8 | satcat5::log::WARNING = 0 |
| | Define basic priority codes for log messages. More...
|
| |
| constexpr s8 | satcat5::log::ERROR = +10 |
| | Define basic priority codes for log messages. More...
|
| |
| constexpr s8 | satcat5::log::CRITICAL = +20 |
| | Define basic priority codes for log messages. More...
|
| |