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]
impl LoggerContextpub fn new<N>(name: N) -> Self where
N: Into<Cow<'static, str>>, [src]
pub fn new<N>(name: N) -> Self where
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());
pub fn name(&self) -> &str[src]
pub fn name(&self) -> &strReturns the associated logging service's name given at construction time.
pub fn create<T>(&self, source: T) -> Logger where
T: Into<Cow<'static, str>>, [src]
pub fn create<T>(&self, source: T) -> Logger where
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.
pub fn filter(&self) -> &Filter[src]
pub fn filter(&self) -> &FilterReturns 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]
impl Clone for LoggerContextfn clone(&self) -> LoggerContext[src]
fn clone(&self) -> LoggerContextReturns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0[src]
fn clone_from(&mut self, source: &Self)Performs copy-assignment from source. Read more
impl Default for LoggerContext[src]
impl Default for LoggerContextimpl Debug for LoggerContext[src]
impl Debug for LoggerContextAuto Trait Implementations
impl Send for LoggerContext
impl Send for LoggerContextimpl Sync for LoggerContext
impl Sync for LoggerContext