Robust and portable logging for embedded projects.
Main docs: Home | The pw_log protobuf | Tokenized log arguments | Backends
Submodules | |
| Global config | |
| Google Logging (glog) macros | |
| Module config | |
| Protobuf helpers | |
| Short macros | |
Optional shortened versions of the PW_LOG macros. | |
| Tokenized args | |
Macros | |
| #define | PW_LOG_LEVEL_DEBUG 1 |
| #define | PW_LOG_LEVEL_INFO 2 |
| #define | PW_LOG_LEVEL_WARN 3 |
| #define | PW_LOG_LEVEL_ERROR 4 |
| #define | PW_LOG_LEVEL_CRITICAL 5 |
| #define | PW_LOG_LEVEL_FATAL 7 |
| #define | PW_LOG_LEVEL_BITS 3 |
| Number of bits required to represent the log level. | |
| #define | PW_LOG_LEVEL_BITMASK 7 |
| #define | PW_LOG( level, verbosity, module, flags, ...) |
| #define | PW_LOG_FLAG_BITS 2 |
| #define | PW_LOG_EVERY_N_DURATION(level, min_interval_between_logs, msg, ...) |
| #define PW_LOG | ( | level, | |
| verbosity, | |||
| module, | |||
| flags, | |||
| ... | |||
| ) |
Accepts the format string and its arguments in a variadic macro. The format string is not listed as a separate argument to avoid adding a comma after the format string when it has no arguments.
| #define PW_LOG_EVERY_N_DURATION | ( | level, | |
| min_interval_between_logs, | |||
| msg, | |||
| ... | |||
| ) |
Logs a message at the given level, only if it hasn't been logged within min_interval_between_logs.
| level | An integer level as defined by pw_log/levels.h |
| min_interval_between_logs | A pw::chrono::SystemClock::duration that defines the minimum time interval between unsuppressed logs |
| msg | Formattable message, same as you would use for PW_LOG or variants |
Includes a summary of how many logs were skipped, and a rough rate in integer seconds.
Intended to supplement and replace widespread use of EVERY_N` for logging. The main benefit this provides is responsiveness for bursty logs. LOG_RATE_LIMITED will log as soon as a burst starts - provided the min_interval_between_logs has elapsed - while EVERY_N may sit idle for a full period depending on the count state.
Note that this will not log until called again, so the summary may include skipped logs from a prior burst.
| #define PW_LOG_FLAG_BITS 2 |
Default: Number of bits available for the log flags
All log statements have a flags field, and this define is the number of bits available for the flags. Some backends restrict this for better efficiency. By default, pick a restricted but large enough value to work for most cases.
| #define PW_LOG_LEVEL_DEBUG 1 |
Standard log levels. Values are limited to 3 bits, to fit within the protobuf definition of LogEntry's line_level in pw_log_rpc. These levels correspond with the log levels from Python's logging library, but have different values.