Giter Club home page Giter Club logo

indicatif-log-bridge's People

Contributors

djugei avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

indicatif-log-bridge's Issues

Is this compatible with flex_logger?

Is this compatible with flexi_logger?

I try to use it like this:

    let _logger = Logger::try_with_str("debug")
        .unwrap()
        .format(opt_format)
        .log_to_file(FileSpec::default().directory("./log"))
        .duplicate_to_stderr(Duplicate::Error)
        .write_mode(WriteMode::BufferAndFlush)
        .start()
        .unwrap();

    let multi_progress = MultiProgress::new();

    LogWrapper::new(multi_progress.clone(), _logger)
        .try_init()
        .unwrap();

I'm getting the following error:

error[E0277]: the trait bound `LoggerHandle: log::Log` is not satisfied
   --> src\main.rs:127:5
    |
127 |     LogWrapper::new(multi_progress.clone(), _logger)
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `log::Log` is not implemented for `LoggerHandle`
    |
    = help: the following other types implement trait `log::Log`:
              &T
              Arc<T>
              Box<T>
              LogWrapper<L>
note: required by a bound in `LogWrapper`
   --> C:\Users\User\.cargo\registry\src\index.crates.io-6f17d22bba15001f\indicatif-log-bridge-0.2.2\src\lib.rs:43:26
    |
43  | pub struct LogWrapper<L: Log> {
    |                          ^^^ required by this bound in `LogWrapper`

I also tried to separate out the flexi_logger call of .start() so that I had a Logger rather than LoggerHandle, but that did not seem to help. Any guidance is greatly appreciated!

Unncessary suspend for disabled log

suspend is unconditionally in log even if that log is not enabled. This may cause unnecessary twinkling of the progress bar. The behavior can be seen in the attached video.

I am using bindgen which will issue many debug logs and warn logs under the hood, but I delibrately filter out most of the bindgen logs. Therefore, it's not possible for me to adjust the number of log macros I call to fix my issue.

fn log(&self, record: &log::Record) {
self.bar.suspend(|| self.log.log(record))
}

Can we modify it to the following? I have verified this modification fixes my issue. Thanks.

    fn log(&self, record: &log::Record) {
        if self.enabled(record.metadata()) {
            self.bar.suspend(|| self.log.log(record))
        } else {
            self.log.log(record)
        }
    }

This can be easily unit tested. Thanks!

indicatif-log-bridge-issue.mp4

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.