Skip to content

Commit 09634b0

Browse files
authored
Add logfire.exception() to logfire-api (#358)
1 parent bbb11ec commit 09634b0

File tree

4 files changed

+7
-2
lines changed

4 files changed

+7
-2
lines changed

logfire-api/logfire_api/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ def warn(self, *args, **kwargs) -> None: ...
6969

7070
def error(self, *args, **kwargs) -> None: ...
7171

72+
def exception(self, *args, **kwargs) -> None: ...
73+
7274
def fatal(self, *args, **kwargs) -> None: ...
7375

7476
def with_tags(self, *args, **kwargs) -> Logfire:
@@ -132,6 +134,7 @@ def shutdown(self, *args, **kwargs) -> None: ...
132134
info = DEFAULT_LOGFIRE_INSTANCE.info
133135
warn = DEFAULT_LOGFIRE_INSTANCE.warn
134136
error = DEFAULT_LOGFIRE_INSTANCE.error
137+
exception = DEFAULT_LOGFIRE_INSTANCE.exception
135138
fatal = DEFAULT_LOGFIRE_INSTANCE.fatal
136139
with_tags = DEFAULT_LOGFIRE_INSTANCE.with_tags
137140
with_settings = DEFAULT_LOGFIRE_INSTANCE.with_settings

logfire-api/logfire_api/__init__.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ from .integrations.logging import LogfireLoggingHandler as LogfireLoggingHandler
1111
from .integrations.structlog import LogfireProcessor as StructlogProcessor
1212
from .version import VERSION as VERSION
1313

14-
__all__ = ['Logfire', 'LogfireSpan', 'LevelName', 'ConsoleOptions', 'PydanticPlugin', 'configure', 'span', 'instrument', 'log', 'trace', 'debug', 'notice', 'info', 'warn', 'error', 'fatal', 'force_flush', 'log_slow_async_callbacks', 'install_auto_tracing', 'instrument_fastapi', 'instrument_openai', 'instrument_anthropic', 'instrument_asyncpg', 'instrument_httpx', 'instrument_celery', 'instrument_requests', 'instrument_psycopg', 'instrument_django', 'instrument_flask', 'instrument_starlette', 'instrument_aiohttp_client', 'instrument_sqlalchemy', 'instrument_redis', 'instrument_pymongo', 'instrument_mysql', 'AutoTraceModule', 'with_tags', 'with_settings', 'shutdown', 'load_spans_from_file', 'no_auto_trace', 'METRICS_PREFERRED_TEMPORALITY', 'ScrubMatch', 'ScrubbingOptions', 'VERSION', 'suppress_instrumentation', 'StructlogProcessor', 'LogfireLoggingHandler', 'TailSamplingOptions']
14+
__all__ = ['Logfire', 'LogfireSpan', 'LevelName', 'ConsoleOptions', 'PydanticPlugin', 'configure', 'span', 'instrument', 'log', 'trace', 'debug', 'notice', 'info', 'warn', 'error', 'exception', 'fatal', 'force_flush', 'log_slow_async_callbacks', 'install_auto_tracing', 'instrument_fastapi', 'instrument_openai', 'instrument_anthropic', 'instrument_asyncpg', 'instrument_httpx', 'instrument_celery', 'instrument_requests', 'instrument_psycopg', 'instrument_django', 'instrument_flask', 'instrument_starlette', 'instrument_aiohttp_client', 'instrument_sqlalchemy', 'instrument_redis', 'instrument_pymongo', 'instrument_mysql', 'AutoTraceModule', 'with_tags', 'with_settings', 'shutdown', 'load_spans_from_file', 'no_auto_trace', 'METRICS_PREFERRED_TEMPORALITY', 'ScrubMatch', 'ScrubbingOptions', 'VERSION', 'suppress_instrumentation', 'StructlogProcessor', 'LogfireLoggingHandler', 'TailSamplingOptions']
1515

1616
DEFAULT_LOGFIRE_INSTANCE = Logfire()
1717
span = DEFAULT_LOGFIRE_INSTANCE.span
@@ -46,4 +46,5 @@ notice = DEFAULT_LOGFIRE_INSTANCE.notice
4646
warn = DEFAULT_LOGFIRE_INSTANCE.warn
4747
error = DEFAULT_LOGFIRE_INSTANCE.error
4848
fatal = DEFAULT_LOGFIRE_INSTANCE.fatal
49+
exception = DEFAULT_LOGFIRE_INSTANCE.exception
4950
__version__ = VERSION

logfire/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ def loguru_handler() -> dict[str, Any]:
9494
'info',
9595
'warn',
9696
'error',
97+
'exception',
9798
'fatal',
9899
'force_flush',
99100
'log_slow_async_callbacks',

tests/test_logfire_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def test_runtime(logfire_api_factory: Callable[[], ModuleType], module_name: str
7070
logfire_api.log('info', 'test log')
7171
logfire__all__.remove('log')
7272

73-
for log_method in ['trace', 'debug', 'info', 'notice', 'warn', 'error', 'fatal']:
73+
for log_method in ['trace', 'debug', 'info', 'notice', 'warn', 'error', 'exception', 'fatal']:
7474
assert hasattr(logfire_api, log_method)
7575
getattr(logfire_api, log_method)('test log')
7676
logfire__all__.remove(log_method)

0 commit comments

Comments
 (0)