Struct cocaine::logging::LoggerContext
[−]
[src]
pub struct LoggerContext { /* fields omitted */ }
A RAII context manager for a logging service.
This is an entry point for a logging service in the cocaine.
The LoggerContext
creates a separate thread where the real logging service with its event
loop lives, and that allows to process all logging events using single TCP connection. The
communication with the context is done using unbounded channel, what makes emitting logging
events just pack-and-send operation.
Note, that the context destruction triggers wait operation until all messages are flushed into the socket.
To create the logger object itself, call create
method, which accepts an optional
source parameter - a short description where a log event came from.
There is also possible to configure a simple severity filter using filter
method.
Methods
impl LoggerContext
[src]
fn new<N>(name: N) -> Self where
N: Into<Cow<'static, str>>,
N: Into<Cow<'static, str>>,
Constructs a new logger context with the given name, that is used as a logging service's name.
Warning
Beware of connecting to a service, which name is just occasionally equals with the specified one. Doing so will probably lead to reconnection after each request because of framing errors.
Examples
use cocaine::logging::LoggerContext; let log = LoggerContext::default(); assert_eq!("logging", log.name()); let log = LoggerContext::new("logging::v2"); assert_eq!("logging::v2", log.name());
fn name(&self) -> &str
Returns the associated logging service's name given at construction time.
fn create<T>(&self, source: T) -> Logger where
T: Into<Cow<'static, str>>,
T: Into<Cow<'static, str>>,
Creates a new logger, that will log events with the given source argument.
All loggers are associated with the context used to create them, i.e share a single underlying service and the filter.
fn filter(&self) -> &Filter
Returns a severity filtering handle.
Changing the severity threshold will affect all loggers that were created using this context.
Trait Implementations
impl Clone for LoggerContext
[src]
fn clone(&self) -> LoggerContext
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more