Struct spirit_log::Cfg[][src]

pub struct Cfg(_);
Expand description

A configuration fragment to set up logging.

By flattening this into the configuration structure, the program can load options for configuring logging. It adds a new top-level array logging. Each item describes one logger, with separate log levels and destination.

See the crate examples for the use.

Logger options

These are valid for all loggers:

  • level: The log level to use. Valid options are OFF, ERROR, WARN, INFO, DEBUG and TRACE.
  • per-module: A map, setting log level overrides for specific modules (logging targets). This one is optional.
  • type: Specifies the type of logger destination. Some of them allow specifying other options.
  • clock: Either LOCAL or UTC. Defaults to LOCAL if not present.
  • time_format: Time format string. Defaults to %+ (which is ISO 8601/RFC 3339). Note that the command line logger (one produced by -l) uses a more human-friendly format.
  • format: The format to use. There are few presets (and a custom may come in future).
    • message-only: The line contains only the message itself.
    • short: This is the default. <timestamp> <level> <target> <message>. Padded to form columns.
    • extended: `. Padded to form columns.
    • full: <timestamp> <level> <thread-name> <file>:<line> <target> <message>. Padded to form columns.
    • machine: Like full, but columns are not padded by spaces, they are separated by a single \t character, for more convenient processing by tools like cut.
    • json: The fields of full are encoded into a json format, for convenient processing of more modern tools like logstash.
    • logstash: json format with fields named and formatted according to Logback JSON encoder

The allowed types are:

  • stdout: The logs are sent to standard output. There are no additional options.
  • stderr: The logs are sent to standard error output. There are no additional options.
  • file: Logs are written to a file. The file is reopened every time a configuration is re-read (therefore every time the application gets SIGHUP), which makes it work with logrotate.
    • filename: The path to the file where to put the logs.
  • network: The application connects to a given host and port over TCP and sends logs there.
    • host: The hostname (or IP address) to connect to.
    • port: The port to use.
  • syslog: Sends the logs to syslog. This ignores all the formatting and time options, as syslog handles this itself. This depends on the to-syslog feature.

Implementations

This provides an Extension to initialize logging.

It calls init and sets up a basic logger (WARN and more serious going to stderr).

This is seldom used directly (but can be), the LogInstaller makes sure it is called.

Checks if the logging configuration is empty.

Can be used for skipping serialization of the config array if empty.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Deserialize this value from the given Serde deserializer. Read more

The default driver to be used by the fragment. Read more

The intermediate product if the fragment supports two-stage creation of Resources. If not, it can be set to (). Read more

The actual product this Fragment creates.

The default installer to be used unless a transformation or the user doesn’t provide one. Read more

Runs the first stage of creation. Read more

Runs the second stage of creation. Read more

Configuration if the pipeline should be run once even before the config is loaded. Read more

Runs both stages of creation at once. Read more

An initialization routine. Read more

Serialize this value into the given Serde serializer. Read more

Returns the documentation for the type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Turns self into the result.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.