GithubHelp home page GithubHelp logo

deinstapel / cursive-flexi-logger-view Goto Github PK

View Code? Open in Web Editor NEW
10.0 4.0 10.0 85 KB

An alternative debug view for gyscos/cursive using emabee/flexi_logger πŸ–₯️

License: BSD 3-Clause "New" or "Revised" License

Shell 11.40% Rust 84.94% jq 3.66%
cursive-views cursive terminal debug view logging flexi-logger

cursive-flexi-logger-view's Introduction

Welcome to cursive-flexi-logger-view πŸ‘‹

stable build nightly build crates.io Docs.rs GitHub PRs Welcome
An alternative debug view for gyscos/cursive using emabee/flexi_logger


This project 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.

How does it look like? demo terminalizer

Expand to view flexi-logger-view demo

Usage

Simply add to your Cargo.toml

[dependencies]
cursive-flexi-logger-view = "^0"

Using the FlexiLoggerView

To create a FlexiLoggerView you first have to register the cursive_flexi_logger as a Writer 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;

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::try_with_env_or_str("trace")
        .expect("Could not create Logger from environment :(")
        .log_to_file_and_writer(
            flexi_logger::FileSpec::default()
                .directory("logs")
                .suppress_timestamp(),
            cursive_flexi_logger_view::cursive_flexi_logger(&siv)
            )
        .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 documentation for a detailed explanation on the API.

Troubleshooting

If you find any bugs/unexpected behaviour or you have a proposition for future changes open an issue describing the current behaviour and what you expected.

Development cargo test

Running the tests

Just run

$ cargo test

to execute all available tests.

shields.io endpoints

shields.io endpoints are generated inside the ./target/shields folder. They are used in this README.

Authors

Fin Christensen

:octocat: @fin-ger
🐘 @[email protected]
🐦 @fin_ger_github


Johannes WΓΌnsche

:octocat: @jwuensche
🐘 @[email protected]
🐦 @Fredowald

Show your support

Give a ⭐ if this project helped you!

cursive-flexi-logger-view's People

Contributors

fin-ger avatar fliegendewurst avatar flowneee avatar gyscos avatar jwuensche avatar matthiasbeyer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

cursive-flexi-logger-view's Issues

flexi logger error

After I start the application I got the error below and how it looks in the app

mintozzy@laptop:~/tmp/storytel-tui$ cargo run
Finished dev [unoptimized + debuginfo] target(s) in 0.50s
Running target/debug/storytel-tui
[flexi_logger][ERRCODE::Time] flexi_logger has to work with UTC rather than with local time, caused by IndeterminateOffset
See https://docs.rs/flexi_logger/latest/flexi_logger/error_info/index.html#time
[flexi_logger][ERRCODE::Write] writing log line failed, caused by Custom { kind: BrokenPipe, error: "cursive callback sink is closed!" }
See https://docs.rs/flexi_logger/latest/flexi_logger/error_info/index.html#write

image

[dependencies]
reqwest = { version = "0.11.11", features = ["json", "blocking"] }
serde = { version = "1.0.139", features = ["derive"] }
serde_json = "1.0.82"
mpv = "0.2.3"
openssl = { version = "0.10.41" }
cursive = { version = "0.18" , default-features = false, features = ["crossterm-backend"]}
cursive-flexi-logger-view = "^0"
flexi_logger = "0.22.6"

I used the example code https://docs.rs/cursive-flexi-logger-view/latest/cursive_flexi_logger_view/#using-the-flexiloggerview

what can be the reason ?

feel free to check https://stackoverflow.com/questions/75200289/cursive-flexi-logger-view-throwing-unhandled-error too.

Thanks

Missing LogWriter trait for FileLogWriter?

After updating to latest flexi_logger 0.28.0 I started getting the following error:1

error[E0277]: the trait bound `CursiveLogWriter: LogWriter` is not satisfied
   --> src/bin/main.rs:180:13
    |
180 |             cursive_flexi_logger_view::cursive_flexi_logger(&cursive)
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `LogWriter` is not implemented for `CursiveLogWriter`
    |
    = help: the trait `LogWriter` is implemented for `FileLogWriter`
    = note: required for the cast from `Box<CursiveLogWriter>` to `Box<(dyn LogWriter + 'static)>`

cargo tree output:

β”œβ”€β”€ cursive-flexi-logger-view v0.5.0
...
β”‚   β”œβ”€β”€ cursive_core v0.3.7 (*)
β”‚   β”œβ”€β”€ flexi_logger v0.22.5

It seems that cursive-flexi-logger-view is pulling in flexi_logger that doesn't match the version I wish to use?

Respect flexilogger writer format

It would be great if the logger-view could use the format that was set on the flexi logger instance. If this is not possible, some other way to override the default styling would be nice.

Update `cursive` and replace with `cursive_core`

As part of the update to 0.15 cursive has migrated their logic (and by that the parts we actually need for this crate) to cursive_core. We should move to use this new crate, for now it requires us to move our end2end tests out of /src into /examples as proposed in our other view crates proposed.

As mentioned in deinstapel/cursive-tabs#5 we can make this work, but the cleaner way to handle the tests is switching to cursive::backends:puppet in all end2end tests.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.