[][src]Crate cursive_flexi_logger_view

A FlexiLoggerView for cursive

This crate provides a new debug view for gyscos/cursive using the emabee/flexi_logger crate. This enables the FlexiLoggerView to respect the RUST_LOG environment variable as well as the flexi_logger configuration file. Have a look at the demo below to see how it looks.

Using the FlexiLoggerView

To create a FlexiLoggerView you first have to register the cursive_flexi_logger as a LogTarget in flexi_logger. After the flexi_logger has started, you may create a FlexiLoggerView instance and add it to cursive.

use cursive::Cursive;
use cursive_flexi_logger_view::FlexiLoggerView;
use flexi_logger::{Logger, LogTarget};

fn main() {
    // we need to initialize cursive first, as the cursive-flexi-logger
    // needs a cursive callback sink to notify cursive about screen refreshs
    // when a new log message arrives
    let mut siv = Cursive::default();

    Logger::with_env_or_str("trace")
        .log_target(LogTarget::FileAndWriter(
            cursive_flexi_logger_view::cursive_flexi_logger(&siv),
        ))
        .directory("logs")
        .suppress_timestamp()
        .format(flexi_logger::colored_with_thread)
        .start()
        .expect("failed to initialize logger!");

    siv.add_layer(FlexiLoggerView::scrollable()); // omit `scrollable` to remove scrollbars

    log::info!("test log message");
    // siv.run();
}

Look into the FlexiLoggerView documentation for a detailed explanation.

Structs

CursiveLogWriter

The flexi_logger LogWriter implementation for the FlexiLoggerView.

FlexiLoggerView

The FlexiLoggerView displays log messages from the cursive_flexi_logger log target. It is safe to create multiple instances of this struct.

Functions

cursive_flexi_logger

Creates a new LogWriter instance for the FlexiLoggerView. Use this to register a cursive log writer in flexi_logger.