GithubHelp home page GithubHelp logo

Comments (4)

emabee avatar emabee commented on July 22, 2024

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.

hasezoey avatar hasezoey commented on July 22, 2024

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.

emabee avatar emabee commented on July 22, 2024

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.

hasezoey avatar hasezoey commented on July 22, 2024

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)

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.