Module log

Source
Expand description

This module is used for logging.

It logs directly to stderr, prefixing log entries with their log level:

>F: Failed to load config files:
 F: IO Error: No such file or directory (os error 2)

For multiline logs, each line gets the log level prefix, but only the first line starts with a >.

§Log Levels

If a certain log level is selected, all logs of this level or above will be shown in the output.

  • Fatal
  • Error
  • Warning
  • Info
  • Debug

§Usage

log::<loglevel>!(<format string>[, <format arguments>]*; <prefix>);

Where

  • loglevel is fatal, error, warning, info, or debug
  • format string and format arguments work like they do in println!, i.e. if println!(...) is valid, then so is log::_!(...; pfx)

§Prefix

The prefix is used to give context to a log entry. It can contain a lobby and/or player id which will then be shown when logging.

§Examples:

log::info!("doing thing now"; &log::pfx());
log::info!("generated not-random value {}", 42; &log::pfx());
let mut pfx = log::pfx();
pfx.lobby(todo!("obtain a lobby id"));
log::info!("my log {}", "message"; &pfx);

See also: Prefix

Re-exports§

pub use _impl::LogLevel;
pub use _impl::Prefix;
pub use _impl::logger;

Modules§

_impl
uuid_human_hash
A way to “hash” the 128-bit UUIDs into two 3-letter words, such as eat-fox, so that humans can more easily refer to lobbies or players (instead of having to read the hex-representation of the UUIDs).

Macros§

debug
debug_force
error
fatal
info
warning

Functions§

pfx
returns a log prefix containing no information.