Skip to content
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

Handle logging None with loguru #331

Merged
merged 2 commits into from
Jul 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions logfire/integrations/loguru.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,21 @@ def fill_attributes(self, record: LogRecord) -> dict[str, Any]:
frame = inspect.currentframe()
while frame: # pragma: no branch
if frame.f_code is _LOG_METHOD_CODE:
msg_template = frame.f_locals.get('message')
if msg_template is not None:
attributes[ATTRIBUTES_MESSAGE_TEMPLATE_KEY] = msg_template
frame_locals = frame.f_locals
if 'message' in frame_locals:
attributes[ATTRIBUTES_MESSAGE_TEMPLATE_KEY] = frame_locals['message']
else: # pragma: no cover
_warn_inspection_failure()

args = frame.f_locals.get('args')
args = frame_locals.get('args')
if isinstance(args, (tuple, list)):
if args:
attributes[ATTRIBUTES_LOGGING_ARGS_KEY] = args
else: # pragma: no cover
_warn_inspection_failure()

if record.exc_info:
original_record = frame.f_locals.get('log_record')
original_record = frame_locals.get('log_record')
if isinstance(original_record, dict):
message = original_record.get('message') # type: ignore
if isinstance(message, str) and record.msg.startswith(
Expand Down