Skip to content

Fix verbose console formatting for some types #1073

@alexmojaki

Description

@alexmojaki
import datetime
import decimal
from enum import Enum, IntEnum, StrEnum

import logfire


class MyEnum(StrEnum):
    foo = 'foo'


class MyEnum2(IntEnum):
    foo = 3


class MyEnum3(Enum):
    foo = 3


logfire.configure(console=logfire.ConsoleOptions(verbose=True))


logfire.info(
    'hi',
    d=datetime.datetime.now(),
    v=decimal.Decimal('1.0'),
)
logfire.info(
    'hi',
    e1=MyEnum.foo,
    e2=MyEnum2.foo,
    e3=MyEnum3.foo,
)

Output:

11:07:08.675 hi
             │ scratch_1499.py:23 info
             │ d=2025-05-14T13:07:08.652694
             │ v=1.0
11:07:08.675 hi
             │ scratch_1499.py:24 info
             │ e1=<MyEnum.foo: 'foo'>
             │ e2=MyEnum2(<MyEnum2.foo: 3>)
             │ e3=MyEnum3(3)

All the values should look like reprs. The enums are an inconsistent mess.

Following up on #1063

Previously these raised errors or did other nonsense, that was fixed in #1071 and #1072

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugBug related to the Logfire Python SDKgood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions