-
Notifications
You must be signed in to change notification settings - Fork 81
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
More lenient handling of loguru message mismatch and better warnings #338
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@alexmojaki Hi, This piece of code will drop the loguru's format, I'm wondering if this is intentional. Because the
replace it with the original message
only worked when the record hasexc_info
, but now it always does the replacement.with
logfire==0.48.0
, outputINFO | 2024-08-13 14:15:37.811 | hello world
with
logfire==0.48.1
, outputhello world
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.
Yes this is intentional. The integration is not designed for a loguru format. The message must be plain because it's also displayed in the UI:
It should just be:
How are you using logfire+loguru? Do you use the UI, or only the console? Does logfire log other non-loguru things to the console without timestamps?
The structlog integration has a
console_log
parameter which should probably be added to the loguru integration, so that logfire just doesn't log loguru logs to the console at all. Then timestamps don't need to be removed from other logs.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.
Thank you. Currently, we use the
loguru
to print JSON logs toconsole
, and then they will be collected toaws.cloudwatch
, so we can do some filterings incloudwatch
, i.e.,$record.extra.xxx = xxx
. It's structured and easy to filter. We are still experimenting with Logfire, it's a great project, thanks. So, both systems are running in parallel, and we don't want any breaking changes oncloudwatch
yet, as there is a lot of predefined filtering in it.with
logfire==0.48.0
, it will print the JSON logs to stderr.with
logfire==0.48.1
, just plain texthello world
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.
if there's a way, we print the JSON logs to
console/stderr
for collection by AWS, and only displayplain text
on the Logfire UI?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.
Take a look at https://pydanticlogfire.slack.com/archives/C06EDRBSAH3/p1719808545882839?thread_ts=1719593610.501669&cid=C06EDRBSAH3
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 don't have permission to visit this Slack thread. But I found that I can add two sinks for
loguru
sys.stderr
, and we can print JSON messages to the console.logfire.loguru_handler()['sink']
, and configure logfire withconsole=False
So, the log messages sent to logfire are pure text, and the messages printed to the console are in JSON format.
Thanks for your help.😊
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.
See https://docs.pydantic.dev/logfire/help/ for the link to join the slack.
Are you not creating any logfire logs/spans outside of integrating with loguru? You're not using any other integrations?