pub struct SimpleLogger { /* private fields */ }
Expand description

Use the SimpleLogger struct to initialize a logger. From then on, the rust log framework should be used to output log statements as usual.

Example

use log::{info, error};
use simplog::SimpleLogger;

SimpleLogger::init(None); // Log level defaults to `Error`
info!("Hello World!");
// Produces nothing
error!("Goodbye World!");
// Produces "Goodbye World"

Implementations

Initialize the logger, with an optionally provided log level (verbosity) in a &str If None is provided -> The log level will be set to Error If ‘Some(`verbosity’) is a &str with a valid log level, the string will be parsed and if valid set as the log level.

Example
use log::info;
use simplog::SimpleLogger;

SimpleLogger::init(Some("info"));
info!("Hello World!");
// Produces "Hello World"

Initialize the logger, with an optionally provided log level (verbosity) in a &str The default log level is Error if None is provided. prefix determines whether each log line output is prefixed with the level that produced it

Example
use log::info;
use simplog::SimpleLogger;

SimpleLogger::init_prefix(Some("info"), true);
info!("Hello World!");
// Produces "INFO   - Hello World"

Initialize the logger, with an optionally provided log level (verbosity) in a &str The default log level is Error if None is provided. prefix determines whether each log line output is prefixed with the level that produced it if timestamp is true, each log line will be prefixed with the elapsed time since the logger was initialized

Example
use log::info;
use simplog::SimpleLogger;

let mut logger = SimpleLogger::init_prefix_timestamp(Some("info"), false, true);
info!("Hello World!");
// Produces "1.246717ms   Hello World"

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Determines if a log message with the specified metadata would be logged. Read more

Logs the Record. Read more

Flushes any buffered records.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.