-
Notifications
You must be signed in to change notification settings - Fork 54
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
missing a way to modify a logfunc to provide context #214
Comments
You may want to consider using |
I'll give it a shot, thanks! (And see if can break this down to an example that might be added to the documentation.) My interim solution is below, but it's a bit unsatisfying in that it sidesteps the RIO logging API a bit.
|
Hmm, no, I don't think I can get the GLog facilities to help here. The thing is, I want to augment the messages with some information from the environment, e.g. the |
@robx I agree that if Would be great to be able to use @snoyberg any thoughts on how this could be achieved? |
Nothing in particular, proposals on concrete changes are welcome. |
I'm having trouble finding a way provide context for log messages while using rio's logging infrastructure, and without creating new log functions all over the place. Below's my understanding of the situation; chances are I'm missing a nice way to achieve this now.
Concretely, for a web request handler, I'd like to extract a client IP address from a header, and prepend that to every logged message.
If
LogFunc
weren't opaque, I could replace theunLogFunc
field with one that preprocesses thestr
argument. Another approach might be to replace or modify thelogFormat
option, but again that's currently not exposed (and the original value is captured by the log function itself currently).It seems to me to be better to not create new log functions for this, since their actions might need to be synchronized.
How I'm imagining using this is by replacing the log function in my environment with a modified version, and using the modified environement via
local
.The text was updated successfully, but these errors were encountered: