Struct fern::Output [] [src]

pub struct Output(_);

Configuration for a logger output.

Methods

impl Output
[src]

[src]

Returns a file logger using a custom separator.

If the default separator of \n is acceptable, an fs::File instance can be passed into Dispatch::chain directly.

fern::Dispatch::new()
    .chain(std::fs::File::create("log")?)
fern::Dispatch::new()
    .chain(fern::log_file("log")?)

Example usage (using fern::log_file):

fern::Dispatch::new()
    .chain(fern::Output::file(fern::log_file("log")?, "\r\n"))

[src]

Returns a logger using arbitrary write object and custom separator.

If the default separator of \n is acceptable, an Box<Write + Send> instance can be passed into Dispatch::chain directly.

fern::Dispatch::new()
    // Explicit cast to the right trait object so the `From` implementation is chosen.
    .chain(Box::new(std::io::Cursor::new(Vec::<u8>::new())) as Box<std::io::Write + Send>)
let writer: Box<std::io::Write + Send> = Box::new(std::io::Cursor::new(Vec::<u8>::new()));
fern::Dispatch::new()
    .chain(fern::Output::writer(Box::new(std::io::Cursor::new(Vec::<u8>::new())), "\r\n"))

[src]

Returns an stdout logger using a custom separator.

If the default separator of \n is acceptable, an io::Stdout instance can be passed into Dispatch::chain() directly.

fern::Dispatch::new()
    .chain(std::io::stdout())

[src]

Returns an stderr logger using a custom separator.

If the default separator of \n is acceptable, an io::Stderr instance can be passed into Dispatch::chain() directly.

fern::Dispatch::new()
    .chain(std::io::stderr())

[src]

Returns a mpsc::Sender logger using a custom separator.

If the default separator of \n is acceptable, an mpsc::Sender<String> instance can be passed into Dispatch::chain() directly.

Each log message will be suffixed with the separator, then sent as a single String to the given sender.

use std::sync::mpsc::channel;

let (tx, rx) = channel();
fern::Dispatch::new()
    .chain(tx)

Trait Implementations

impl From<Dispatch> for Output
[src]

[src]

Creates an output logger forwarding all messages to the dispatch.

impl From<Box<Log>> for Output
[src]

[src]

Creates an output logger forwarding all messages to the custom logger.

impl From<&'static Log> for Output
[src]

[src]

Creates an output logger forwarding all messages to the custom logger.

impl From<File> for Output
[src]

[src]

Creates an output logger which writes all messages to the file with \n as the separator.

File writes are buffered and flushed once per log record.

impl From<Box<Write + Send>> for Output
[src]

[src]

Creates an output logger which writes all messages to the writer with \n as the separator.

This does no buffering and it is up to the writer to do buffering as needed (eg. wrap it in BufWriter). However, flush is called after each log record.

impl From<Stdout> for Output
[src]

[src]

Creates an output logger which writes all messages to stdout with the given handle and \n as the separator.

impl From<Stderr> for Output
[src]

[src]

Creates an output logger which writes all messages to stderr with the given handle and \n as the separator.

impl From<Sender<String>> for Output
[src]

[src]

Creates an output logger which writes all messages to the given mpsc::Sender with '\n' as the separator.

All messages sent to the mpsc channel are suffixed with '\n'.

impl From<Logger> for Output
[src]

[src]

Creates an output logger which writes all messages to the given syslog output.

Log levels are translated trace => debug, debug => debug, info => informational, warn => warning, and error => error.

impl From<Box<Logger>> for Output
[src]

[src]

Creates an output logger which writes all messages to the given syslog output.

Log levels are translated trace => debug, debug => debug, info => informational, warn => warning, and error => error.

Note that while this takes a Box for convenience (syslog methods return Boxes), it will be immediately unboxed upon storage in the configuration structure. This will create a configuration identical to that created by passing a raw syslog::Logger.

impl From<Panic> for Output
[src]

[src]

Creates an output logger which will panic with message text for all messages.

impl Debug for Output
[src]

[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl Send for Output

impl !Sync for Output