You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Can logfire provide a logging format configuration with access to LogRecord Attributes for logs written to stdout? The API can be as simple as adding an argument like logfire.configure(format="<format_string>").
The stdout logger is not configurable by means provided to the end user (as far as I can tell) and it really doesn't provide enough information to be useful (filename, line number, etc.). Integrating logfire into the stdlib logger via LogfireLoggingHandler might allow for custom formats but, per the documentation, using logfire directly is recommended.
current:
importlogfirelogfire.configure()
logfire.info("log this message") # 23:04:47.846 log this message
proposed:
importlogfirelog_format="%(asctime)s - %(filename)s -%(lineno)d - %(message)s"logfire.configure(format=log_format)
logfire.info("log this message") # 2024-10-08 16:49:45,896 - file.py - 16 - log this message
The text was updated successfully, but these errors were encountered:
I agree that we need to make console logging more flexible and customizable in a user friendly way. Unfortunately it's not easy. The objects we have are OpenTelemetry spans, not LogRecords. Here's a rough demo of what you can do now:
But the filename and lineno won't always be available, and this will log two lines for every non-log span (the first being for the pending span), and there's probably other complications.
Description
Can logfire provide a logging format configuration with access to LogRecord Attributes for logs written to stdout? The API can be as simple as adding an argument like
logfire.configure(format="<format_string>")
.The stdout logger is not configurable by means provided to the end user (as far as I can tell) and it really doesn't provide enough information to be useful (filename, line number, etc.). Integrating logfire into the stdlib logger via LogfireLoggingHandler might allow for custom formats but, per the documentation, using logfire directly is recommended.
current:
proposed:
The text was updated successfully, but these errors were encountered: