djugei / indicatif-log-bridge Goto Github PK
View Code? Open in Web Editor NEWbridges the log crate and indicatif to stop the progress bars and log lines from mixing up
bridges the log crate and indicatif to stop the progress bars and log lines from mixing up
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!
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.
indicatif-log-bridge/src/lib.rs
Lines 87 to 89 in 51dc006
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!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.