Struct quil::Logger
[−]
[src]
pub struct Logger { /* fields omitted */ }
Logger has methods for logging messages from your program. This struct is the heart of Quil. Logger is clonable and can be send across threads safely.
Examples
Create a basic logger and log a message:
let logger = Logger::new(Console::new(), context!{}); logger.info("Hello world");
Methods
impl Logger
[src]
fn new<T>(target: T, context: Context) -> Self where
T: Target + 'static,
[src]
T: Target + 'static,
Creates a new logger from a target and context.
The target can be any type that implements the
Target
trait. If you wish to use more than one
target with your logger It's recomended you use the
TargetSet
via the
targets!
macro. The
Context
contains any contextual meta data
you want to pass to the target with each log message. It's recommended
you use the context
macro to create your
Context
.
See Logger
examples above.
Arguments
target
- The target the logger will log to.context
- The context that will be passed with each log message. to the target.
fn set_level<L>(&self, level: L) where
L: Into<Level>,
[src]
L: Into<Level>,
Changes the logger's loggin level.
Note that this will change the level for all loggers that share the same ancestor.
Arguments
level
- The log level you'd like to set.
fn set_target<T>(&self, target: T) where
T: Target + 'static,
[src]
T: Target + 'static,
Changes the logger target.
Note that this will change the target for all loggers that share the same ancestor.
Arguments
target
- The target you'd like the logger to use.
fn ctx(&self, context: Context) -> Self
[src]
Creates a new logger with an extended context.
The returned logger with have a context containing all values from
the logger ctx
is called upon and the given context. Keys that
are present in both contexts will be overwritten by the given context.
If you want to remove a key that was set in the original logger set the value of the key to an empty string literal. This will remove it from the new logger.
Arguments
context
- A context containing meta data for the new logger.
Examples
Basic example of using ctx
to create a sub logger:
let logger = Logger::new(Console::new(), context!{ src: "root" }); logger.info("hello"); let sub_logger = logger.ctx(context!{ src: "sub_root" }); logger.info("world");
Tue, 7 Nov 2017 23:55:42 +0000 - info: hello src=root
Tue, 7 Nov 2017 23:55:42 +0000 - info: world src=sub_root
Example of removing a key:
let logger = Logger::new(Console::new(), context!{ src: "root" }); logger.info("hello"); let sub_logger = logger.ctx(context!{ src: "" }); logger.info("world");
Tue, 7 Nov 2017 23:55:42 +0000 - info: hello src=root
Tue, 7 Nov 2017 23:55:42 +0000 - info: world
fn error(&self, message: &str)
[src]
Log an error message.
It's recommended to use this method only to log errors.
Arguments
message
- A pointer the message to log.
fn warn(&self, message: &str)
[src]
Log a warning message.
It's recommended to use this method only to log warnings.
Arguments
message
- A pointer the message to log.
fn info(&self, message: &str)
[src]
Log an informational message.
It's recommended to use this method for messages that should be seen by operators of your application without debugging enabled.
Arguments
message
- A pointer the message to log
fn verbose(&self, message: &str)
[src]
Log an verbose message.
It's recommended to use this method for messages that should only be seen if an operator needs to see a bit more than the info level.
Note that verbose is not the same as trace. It's intented to allow for a bit of extra informational detail.
Arguments
message
- A pointer the message to log
fn debug(&self, message: &str)
[src]
Log an debug message.
It's recommended to use this method for messages that should only be seen if an operator or developer needs a debug information.
Any messages at this level should be intented to help operators and developers understand what is happening in your application without a full on trace.
Arguments
message
- A pointer the message to log
fn trace(&self, message: &str)
[src]
Log an trace message.
It's recommended to use this method for messages that should only be seen if an operator or developer needs a trace information.
Trace should be used to explain to developers and operators what is happening at a low level within the application.
Arguments
message
- A pointer the message to log
fn log<L>(&self, level: L, message: &str) where
L: Into<Level>,
[src]
L: Into<Level>,
Log a message.
It's recomended to use one of the level bound methods above instead of
log
. However if you want to select the log level dynamically this
method can be used.
Arguments
message
- A pointer the message to log
Trait Implementations
impl Clone for Logger
[src]
fn clone(&self) -> Logger
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more