Crate pw_log

Source
Expand description

pw_log is an extensible logging system that can delegate to pre-existing logging APIs without upstream changes.

Clients of pw_log simply import and use the logging API, and log invocations will be handled by the provided logging backend.

This flexibility is accomplished using Pigweed’s facade pattern, which uses build-system redirection to forward log invocations to the configured backend implementation.

use pw_log::{log, info, LogLevel};

log!(LogLevel::Info, "Thank you for signing up for Log Facts!");
info!("Log Fact: Logs can be either {}, {}, or {} sawn.",
  "flat" as &str, "quarter" as &str, "rift" as &str);

Today printf style format strings are well supported with Rust core::fmt/println!() style strings partially supported (b/311232607).

Currently, when using a stable toolchain, “untyped” arguments (i.e. {} style) need to be in the form of an as-cast. Users with nightly toolchains can enable the nightly_tait feature to remove this restriction.

TODO: <pwbug.dev/311266298> - Document pw_log’s backend API.

TODO: <pwbug.dev/311232605> - Document how to configure facade backends.

Macros§

critical
Emit a critical level log message using core::fmt format string semantics.
criticalf
Emit a critical level log message using printf format string semantics.
debug
Emit a debug level log message using core:fmt format string semantics.
debugf
Emit a debug level log message using printf format string semantics.
error
Emit an error level log message using core::fmt format string semantics.
errorf
Emit an error level log message using printf format string semantics.
fatal
Emit a fatal level log message using core::fmt format string semantics.
fatalf
Emit a fatal level log message using printf format string semantics.
info
Emit an info level log message using core:fmt format string semantics.
infof
Emit an info level log message using printf format string semantics.
log
Emit a log message using core::fmt format string semantics.
logf
Emit a log message using printf format string semantics.
pw_log_criticalf
Deprecated alias for criticalf!.
pw_log_debugf
Deprecated alias for debugf!.
pw_log_errorf
Deprecated alias for errorf!.
pw_log_fatalf
Deprecated alias for fatalf!.
pw_log_infof
Deprecated alias for infof!.
pw_log_warnf
Deprecated alias for warnf!.
pw_logf
Deprecated alias for logf!.
warn
Emit a warn level log message using core::fmt format string semantics.
warnf
Emit a warn level log message using printf format string semantics.

Enums§

LogLevel
Pigweed’s standard log levels