Crate slog_html [] [src]

Html formatter for slog-rs

Examples

Writing logs to an HTML file

#[macro_use]
extern crate slog;
extern crate slog_html;
extern crate slog_stream;

use slog::DrainExt;

use std::fs::OpenOptions;

fn main() {
    let file = OpenOptions::new()
        .create(true)
        .write(true)
        .truncate(true)
        .open("target/log.html").unwrap();

    let log = slog::Logger::root(
        slog_stream::stream(
            file,
            slog_html::default()
        ).fuse(),
        o!("version" => env!("CARGO_PKG_VERSION"))
    );

    debug!(log, "debug values"; "x" => 1, "y" => -1);
}

Create HTML logger with custom options

Use a greyscale color palette for the log levels and disable boldness for the message part.

            slog_html::new()
                .compact()
                .color_palette(slog_html::ColorPalette {
                    critical: "000000",
                    error: "1e1e1e",
                    warning: "3c3c3c",
                    info: "5a5a5a",
                    debug: "787878",
                    trace: "969696",
                })
                .message_style(slog_html::Style {
                    bold: false,
                    .. slog_html::Style::default()
                })
                .build()

Structs

ColorPalette

Hexadecimal color codes

Format

Html formatter

FormatBuilder

Streamer builder

Style

Formatting style

Enums

FormatMode

Formatting mode

Functions

default

Default html Format

new

Create new FormatBuilder to create Format

timestamp_local

Default local timestamp function used by Format

timestamp_utc

Default UTC timestamp function used by Format

Type Definitions

TimestampFn

Timestamp function type