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]

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());

Returns the associated logging service's name given at construction time.

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.

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]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Default for LoggerContext
[src]

Returns the "default value" for a type. Read more

impl Debug for LoggerContext
[src]

Formats the value using the given formatter.