Crate smlog

Source
Expand description

§smlog: a lightweight and very basic stdout logging implementation

Useful for basic human-readable logging, and not much else

Rather than other logging implementations, this logger is extremely opinionated for the sake of simplicity. The lack of choice means that you should be able to call smlog::Log::init(...) once in main and immediately start logging using log’s logging macros, without adding a significant amount of bloat to your project.

§Log formatting

Your log statements will look extremely basic:

  • info!(...) prints info: ...
  • warn!(...) prints warning: ...
  • error!(...) prints error: ...
  • debug!(...) prints debug: ...
  • trace!(...) prints trace: ...

but sometimes, that’s all you really need.

§Examples:

§Basic logging

use smlog::{log::{info, error}, Log, LevelFilter};

fn main() {
    Log::init(LevelFilter::Info);

    info!("Hello, world!");
    // Outputs `info: Hello, world!`

    error!("Goodbye, world!");
    // Outputs `error: Goodbye, world!`
}

Re-exports§

pub use log;

Macros§

debug
Logs a message at the debug level.
error
Logs a message at the error level.
info
Logs a message at the info level.
trace
Logs a message at the trace level.
warn
Logs a message at the warn level.

Structs§

Log
A quick-and-dirty logging implementation

Functions§

allow
Explicitly allows the module specified by target
ignore
Ignores the module specified by target