What's a log?

A 1D list of tuple:

list[tuple[datetime, Level, str]]
[
	(datetime(...), 'info',    'GET /accounts/invoice/ -> 200'),
    (datetime(...), 'info',    'GET /add-on/complete/ -> 200'),
    (datetime(...), 'error',   'Stripe payment failed, insuff...'),
    (datetime(...), 'warning', 'POST /payments/42/complete/ -> 400'),
    (datetime(...), 'warning', 'POST /payments/37/complete/ -> 400'),
    (datetime(...), 'debug',   'Slow query detected SELECT...'),
]

This is what code looked like...

until about 1980

How it should be

A nested structure:

class Log(TypedDict):
    start: datetime
    end: datetime | None
    message: str
    attributes: dict[str, Any] | None
    children: list[Log] | None

list[Log]

What we proposing here isn't new, but it's still not available to most developers

[
    Log(
        start=datetime(...),
        end=datetime(...),
        message='POST /payments/42/complete/ -> 400',
        children=[
            Log(
                start=datetime(...),
                message='Stripe payment failed, insuff...',
                attributes={'reason': 'insufficent funds', ...}
            ),
        ]
    )
]

Simple to get started

Built on Open Telemetry

Customised for Python

But Usable with any Language

Traces as Logs, and Metrics

Auto-tracing

Structured Data

 

Thank you

$1000 Logfire credit: pydantic.dev/euro24

Logfire - Django London September 2024

By samuelcolvin-pydantic

Logfire - Django London September 2024

Pydantic Logfire - Why we built it and why you should try it

  • 150