Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configured level filters aren't respected in combined loggers #159

Open
Calandiel opened this issue Oct 1, 2024 · 1 comment
Open

Configured level filters aren't respected in combined loggers #159

Calandiel opened this issue Oct 1, 2024 · 1 comment

Comments

@Calandiel
Copy link

Consider the following code:

	let config = ConfigBuilder::default()
		.set_time_level(LevelFilter::Error)
		.set_location_level(LevelFilter::Error)
		.build();
	let _ = CombinedLogger::init(vec![
		TermLogger::new(
			LevelFilter::Trace,
			config.clone(),
			TerminalMode::Mixed,
			ColorChoice::Auto,
		),
		WriteLogger::new(
			LevelFilter::Trace,
			config,
			File::create("file.log").expect("Failed to create a file logger!"),
		),
	])
	.expect("Failed to create a combined logger!");

It will print time level and location data for all message levels (not just error). The only way I found to modify the behavior was to use the Off level, which does turn it off but it does so for all levels, which is quite different and nowhere near as useful.

@Calandiel
Copy link
Author

Calandiel commented Oct 1, 2024

Well, after playing around with it some more, I'm wondering if it's not due to me misunderstanding the intended purpose of these methods.

I assumed you're supposed to use it to sort of limit the information "from above", so to speak. As in, if you set a location filter to, say, info, I'd expect error to still print in full detail (as surely it's more important to know the location then than for every trace).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant