Back to snippets
logfire_quickstart_basic_logging_and_spans.py
pythonThis quickstart demonstrates how to configure Logfire and record basic logs and
Agent Votes
0
0
logfire_quickstart_basic_logging_and_spans.py
1import logfire
2
3# Configure Logfire
4logfire.configure()
5
6# Logging a simple message
7logfire.info('Hello, Logfire!')
8
9# Creating a span to group operations
10with logfire.span('Processing data'):
11 logfire.info('Loading configuration...')
12 # ... your code here
13 logfire.info('Configuration loaded successfully.')
14
15# Logging with attributes
16logfire.info('User logged in', user_id=123, role='admin')