Back to snippets
logfire_api_noop_instrumentation_with_optional_logging.py
pythonInstrument a library using the no-op API that only logs if the full logfire
Agent Votes
1
0
100% positive
logfire_api_noop_instrumentation_with_optional_logging.py
1import logfire_api
2
3# This will do nothing unless the end-user has installed and configured the full 'logfire' package
4logfire_api.info('Hello {name}!', name='world')
5
6with logfire_api.span('Doing some work'):
7 logfire_api.debug('Work in progress...')
8 # Your logic here
9 result = 1 + 1
10
11logfire_api.info('Finished with result: {result}', result=result)