mirror of
https://github.com/d3vyce/fastapi-toolsets.git
synced 2026-03-01 17:00:48 +01:00
chore: documentation (#76)
* chore: update docstring example to use python code block * docs: add documentation * feat: add docs build + fix other workdlows * fix: add missing return type
This commit is contained in:
37
docs/module/logger.md
Normal file
37
docs/module/logger.md
Normal file
@@ -0,0 +1,37 @@
|
||||
# Logger
|
||||
|
||||
Lightweight logging utilities with consistent formatting and uvicorn integration.
|
||||
|
||||
## Overview
|
||||
|
||||
The `logger` module provides two helpers: one to configure the root logger (and uvicorn loggers) at startup, and one to retrieve a named logger anywhere in your codebase.
|
||||
|
||||
## Setup
|
||||
|
||||
Call [`configure_logging`](../reference/logger.md#fastapi_toolsets.logger.configure_logging) once at application startup:
|
||||
|
||||
```python
|
||||
from fastapi_toolsets.logger import configure_logging
|
||||
|
||||
configure_logging(level="INFO")
|
||||
```
|
||||
|
||||
This sets up a stdout handler with a consistent format and also configures uvicorn's access and error loggers so all log output shares the same style.
|
||||
|
||||
## Getting a logger
|
||||
|
||||
```python
|
||||
from fastapi_toolsets.logger import get_logger
|
||||
|
||||
logger = get_logger(name=__name__)
|
||||
logger.info("User created")
|
||||
```
|
||||
|
||||
When called without arguments, [`get_logger`](../reference/logger.md#fastapi_toolsets.logger.get_logger) auto-detects the caller's module name via frame inspection:
|
||||
|
||||
```python
|
||||
# Equivalent to get_logger(name=__name__)
|
||||
logger = get_logger()
|
||||
```
|
||||
|
||||
[:material-api: API Reference](../reference/logger.md)
|
||||
Reference in New Issue
Block a user