Struct simplog::SimpleLogger
source · [−]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
sourceimpl SimpleLogger
impl SimpleLogger
sourcepub fn init(verbosity: Option<&str>)
pub fn init(verbosity: Option<&str>)
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"
sourcepub fn init_prefix(verbosity: Option<&str>, prefix: bool)
pub fn init_prefix(verbosity: Option<&str>, prefix: bool)
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"
sourcepub fn init_prefix_timestamp(
verbosity: Option<&str>,
prefix: bool,
timestamp: bool
)
pub fn init_prefix_timestamp(
verbosity: Option<&str>,
prefix: bool,
timestamp: bool
)
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
sourceimpl Clone for SimpleLogger
impl Clone for SimpleLogger
sourcefn clone(&self) -> SimpleLogger
fn clone(&self) -> SimpleLogger
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
Auto Trait Implementations
impl RefUnwindSafe for SimpleLogger
impl Send for SimpleLogger
impl Sync for SimpleLogger
impl Unpin for SimpleLogger
impl UnwindSafe for SimpleLogger
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more