Skip to content

Commit

Permalink
cleaner fix
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelcolvin committed Jan 29, 2025
1 parent 123c7e4 commit 786b0ab
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
18 changes: 9 additions & 9 deletions logfire/_internal/exporters/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,23 +182,23 @@ def _details_parts(self, span: ReadableSpan, indent_str: str) -> TextParts:
if not self._verbose or not span.attributes:
return []

file_location = str(span.attributes.get('code.filepath'))
file_location_raw = span.attributes.get('code.filepath')
file_location = None if file_location_raw is None else str(file_location_raw)
if file_location:
lineno = span.attributes.get('code.lineno')
if lineno: # pragma: no branch
file_location += f':{lineno}'

log_level_num: int = span.attributes.get(ATTRIBUTES_LOG_LEVEL_NUM_KEY) # type: ignore
log_level = NUMBER_TO_LEVEL.get(log_level_num, '')
log_level = NUMBER_TO_LEVEL.get(log_level_num)

if file_location or log_level:
return [
(indent_str, ''),
('│', 'blue'),
(' ', ''),
(file_location, 'cyan'),
(f' {log_level}', ''),
]
parts: TextParts = [(indent_str, ''), ('│', 'blue'), (' ', '')]
if file_location:
parts.append((file_location, 'cyan'))
if log_level:
parts.append((f' {log_level}', ''))
return parts
else:
return []

Expand Down
2 changes: 1 addition & 1 deletion tests/test_console_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def test_simple_console_exporter_no_colors_verbose(simple_spans: list[ReadableSp
[
'00:00:01.000 rootSpan',
'00:00:02.000 childSpan 1',
' │ testing.py:42 ',
' │ testing.py:42',
]
)

Expand Down

0 comments on commit 786b0ab

Please sign in to comment.