-
Notifications
You must be signed in to change notification settings - Fork 8
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
Add default extra fields to messages #40
Comments
This is already possible with (abusing) Filters! And since this is actually something I also needed, lgr already includes a constructor for Filters for your exact usecase!
see you can afterwards remove the filter with |
Genius! Is this described somewhere in the docs? Maybe a short vignette or a blog post would be nice, I think this is fairly common use-case in data processing. |
Ok great that it works :) No it's not super well documented yet, only in the help of I'm leaving this issue open because I agree it should be better documented (how it works, and also WHY it works). Sadly, refining the documentation is a lot of work :(. In the meanwhile, note that lgr is basically a very close clone of python logging and most of the documentation of python logging applies - with small modifications - also to lgr (in this case Filter Objects) |
I just saw, this was actually documented in the vignette already, I just forgot about it ;) I gave the section a slightly better heading now. |
I have a json appender where I would like to automatically add some meta-data without having to specify them in the log function every time.
For example, I have a loop which operates on some entities, I'd like to automatically add the entity ID to each log message emitted in the loop.
The motivation is removal of extra clutter in the logging code, where often I'd have 4-5 extra arguments which don't change inside the entire function/loop body.
In code (non-working):
Both logs would include the
a
andid
extra keys without me having to specify them repeatedly.The text was updated successfully, but these errors were encountered: