Comments (4)
There are now methods LoggerHandle::adapt_duplication_to_stderr
and LoggerHandle::adapt_duplication_to_stdout
which take a Duplicate
as parameter. Hope that fits :-)
from flexi_logger.
sadly doing the following:
logger_handle
.adapt_duplication_to_stderr(flexi_logger::Duplicate::None)
.expect("Expected to be able to adapt duplication");
does not actually fully address my issue, i wanted a way to disable stderr
/ stdout
(or maybe any other specific target) output of logging regardless of if duplication
is activated (in my case logging to file, and so duplication is conditional - a cli argument)
currently if run without duplication, a Err
appears (for testing via .expect
):
thread 'main' panicked at 'Expected to be able to adapt duplication: NoFileLogger', crates/mh/src/main.rs:190:18
and in the case of the err being ignored, it still prints to the stderr, which messes up the TUI, my workaround for now is / was to not duplicate logging and if no file-logging is enabled to fully disable the logger via logger_handle.set_new_spec(LogSpecification::off());
from flexi_logger.
Wouldn't it be sufficient for your case to not call logger_handle.adapt_duplication_to_stderr
if duplication was not configured in the first place?
from flexi_logger.
well i just think the following is not really a great implementation:
info!("Disabling stderr logging");
if !cli_matches.log_options.log_to_file {
logger_handle.set_new_spec(LogSpecification::off());
} else {
let _ = logger_handle.adapt_duplication_to_stderr(flexi_logger::Duplicate::None);
}
when what i suggested in the original description would be:
info!("Disabling stderr logging");
logger_handle.disable(enum::stderr); // or any of the other proposed versions
but i guess this works for now
from flexi_logger.
Related Issues (20)
- Get all log files include rolling
- There is no line number in the log? HOT 2
- How to reopen the output file of a FileLogWriter after Logger::add_writer took it over? HOT 2
- Dynamic logging for parent/daemon HOT 1
- bufsize in std_writer::AsyncHandle HOT 2
- Missing `regex` and `log` dependencies - fail to compile HOT 1
- Method on LoggerHandle for manually forcing rotation?
- Remove remnants of the external_rotation feature
- Rotation may overwrite existing log file HOT 9
- Different logger instances per thread? HOT 1
- GlobError unwrap happens HOT 3
- [trc] Improve usability by getting values from `Logger` or integrating with it HOT 1
- `kv` support from log crate. Json formatter. HOT 2
- Does this library support multiple log files and/or multiple named/filtered outputs? HOT 1
- Add new file logged on the fly HOT 8
- creating vs modification time HOT 1
- TimestampsCustomFormat with empty current_infix HOT 1
- FileLogWriter does not follow its max_level HOT 1
- Custom logging level HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flexi_logger.