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§

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

Enums§