-
Notifications
You must be signed in to change notification settings - Fork 301
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
Include source in StreamLogHandler output #189
Conversation
Can one of the admins verify this patch? |
8 similar comments
Can one of the admins verify this patch? |
Can one of the admins verify this patch? |
Can one of the admins verify this patch? |
Can one of the admins verify this patch? |
Can one of the admins verify this patch? |
Can one of the admins verify this patch? |
Can one of the admins verify this patch? |
Can one of the admins verify this patch? |
I am personally happy with this PR, so good to go from my side :). Said that, we kinda intentionally made |
@swift-server-bot test this please |
Motivation: When using the same Logger across an application in combination with the default StreamLogHandler, it may be difficult to differentiate between logs produced by different modules. ServiceLifecycle works around this by prepending the log message with [Lifecycle], which is what I'd like to do StreamLogHandler by default, leveraging the source log parameter. Modifications: StreamLogHandler will include the source in brackets right before the log message when writing a log. Result: Logs from different modules are easily differentiable when produced using the same Logger instance.
@swift-server-bot add to allowlist |
Good point! Although one could also argument that having it as a reference point for "better" implementations would also be beneficial, so including it could motivate other impls to do the same. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this and to @slashmo's point: We should educate logging backend builders to include source
in their logs. One of the most effective ways is likely to just include it in the StreamLogger. So deffo +1 here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, LGTM from my end as well.
Our backend is known to try to be intentionally not great, but it should not drop data is has already. I was surprised we didn't log the source, so definitely +1.
Thanks a lot for noticing @slashmo !
Include source in StreamLogHandler output.
Motivation:
When using the same Logger across an application in combination with the default StreamLogHandler, it may be difficult to differentiate between logs produced by different modules. ServiceLifecycle works around this by prepending the log message with [Lifecycle], which is what I'd like to do StreamLogHandler by default, leveraging the source log parameter.
Modifications:
StreamLogHandler will include the source in brackets right before the log message when writing a log.
Result:
Logs from different modules are easily differentiable when produced using the same Logger instance.