Types

We need basic types from the actix crate and import some types from the syslog crate:

use actix::{Actor, Context, Handler, Message};
use syslog::{Facility, Formatter3164, Logger, LoggerBackend};

We don't need to study the syslog crate in detail, but let's discuss basic some types.

You can also use use actix::prelude::*; to import all most-used types from the actix crate.

Logger is a main struct that allows writing methods to add records to syslog. It includes logging the methods order by level from highest to lowest: emerg, alert, crit, err, warning, notice, info, debug. The LoggerBackend enum specifies the type of a connection to a logger. It can be a socket or UNIX socket. The Facility enum specifies the type of application which writes logs. Formatter3164 specifies the format of logging.

There are two Syslog protocols described in two RFCs: 3164 and 5424. That's why formatters have such strange names.

Now we can implement the logging actor.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.143.22.23