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

logging off for specific modules #26

Closed
thepixelmonk opened this issue Apr 27, 2019 · 9 comments
Closed

logging off for specific modules #26

thepixelmonk opened this issue Apr 27, 2019 · 9 comments

Comments

@thepixelmonk
Copy link

thepixelmonk commented Apr 27, 2019

Is it possible to turn logging completely off for certain modules? Something like:

with_str("warn, mymodule=off")
@emabee
Copy link
Owner

emabee commented Apr 27, 2019

Yes, exactly this is possible.
Example:
Logger::with_env_or_str("info, mymod1=debug, mymod2=error, mymod1::mysubmod = off")
will not log any messages from mymod1::mysubmod, although mymod1is set to "debug".

@thepixelmonk
Copy link
Author

nice, thanks for the clarification.

@thepixelmonk
Copy link
Author

thepixelmonk commented Apr 28, 2019

so.. if I try using:

with_str("info, rocket=off")

I still see a bunch of output from rocket in the logfile:

INFO [rocket::rocket] 🔧 Configured for production.
INFO [rocket::rocket] address: ^[[1;49;39m0.0.0.0^[[0m
INFO [rocket::rocket] port: ^[[1;49;39m10000^[[0m
INFO [rocket::rocket] log: ^[[1;49;39moff^[[0m
INFO [rocket::rocket] workers: ^[[1;49;39m16^[[0m
INFO [rocket::rocket] secret key: ^[[1;49;39mprovided^[[0m
INFO [rocket::rocket] limits: ^[[1;49;39mforms = 32KiB^[[0m
INFO [rocket::rocket] keep-alive: ^[[1;49;39m5s^[[0m
INFO [rocket::rocket] tls: ^[[1;49;39mdisabled^[[0m
INFO [rocket::rocket] ^[[33m[extra]^[[0m template_dir: ^[[1;49;39m"templates"^[[0m
INFO [rocket::rocket] ^[[33m[extra]^[[0m databases: ^[[1;49;39m{ redis = { url = "redis://localhost" } }^[[0m

if I use:

with_str("mymodule")

I don't see any output from rocket and only output from mymodule. Any ideas?

@thepixelmonk thepixelmonk reopened this Apr 28, 2019
@emabee
Copy link
Owner

emabee commented Apr 28, 2019 via email

@emabee
Copy link
Owner

emabee commented May 15, 2019

Fixed with 0.11.5 which is available now on crates.io

@thepixelmonk
Copy link
Author

I'm now on 0.11.5 and using with_env_or_str("info, rocket=off, serenity=off"), but am still seeing the following in stdout:

ERROR [rocket::rocket] No matching routes for GET /index.php.
WARN [rocket::rocket] Responding with 404 Not Found catcher.

@emabee
Copy link
Owner

emabee commented May 19, 2019

Rocket uses the log crate in a pretty unusual way, by specifying the „target“ explicitly.
Unfortunately, the log crate is not very clear about the semantics of „target“.
The log macros fill it with the module path, and the log crate once recommended (iirc) and now states that most loggers use „target“ for filtering.
But log records also come with a „module path“, which contains by default the same info as „target“.
I have to experiment a bit. There are chances to make this cleaner, I think.

The log crate should define the semantics of target more precisely.

@emabee emabee reopened this May 19, 2019
@emabee
Copy link
Owner

emabee commented May 20, 2019

I really think that rocket overstretches the possibilities of the log crate. I doesn't seem to be a good idea that libraries choose to log to different targets.

Nevertheless, there's a new flexi_logger version on master that should solve the issues with rocket for now. The fix has impact on the API for additional writers (which are addressed via the target info), so it is an alpha version of 0.12.

I will need to merge some other stuff in and polish before I can publish on crates.io.

@emabee
Copy link
Owner

emabee commented May 24, 2019

Version 0.12.0 is now published and should work with rocket as expected!

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

No branches or pull requests

2 participants