Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion docs/introduction/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,18 @@ Additional parameters:
- `logging_flush_level`
- `logging_buffer_capacity`
- `logging_extra_processors`
- `logging_unset_handlers`.
- `logging_unset_handlers`
- `logging_time_stamper` - a `structlog.processors.TimeStamper` instance controlling timestamp format (default: `TimeStamper(fmt="iso")`). Pass a custom instance to change the format or enable UTC:

```python
import structlog
from lite_bootstrap import FastAPIConfig

config = FastAPIConfig(
service_debug=False,
logging_time_stamper=structlog.processors.TimeStamper(fmt="%Y-%m-%d %H:%M:%S", utc=True),
)
```

### Structlog Litestar

Expand Down
3 changes: 2 additions & 1 deletion lite_bootstrap/instruments/logging_instrument.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ class LoggingConfig(BaseConfig):
logging_unset_handlers: list[str] = dataclasses.field(
default_factory=list,
)
logging_time_stamper: "structlog.processors.TimeStamper | None" = None


@dataclasses.dataclass(kw_only=True, slots=True, frozen=True)
Expand All @@ -110,7 +111,7 @@ def structlog_pre_chain_processors(self) -> list[typing.Any]:
structlog.stdlib.add_logger_name,
tracer_injection,
structlog.stdlib.PositionalArgumentsFormatter(),
structlog.processors.TimeStamper(fmt="%Y-%m-%d %H:%M:%S"),
self.bootstrap_config.logging_time_stamper or structlog.processors.TimeStamper(fmt="iso"),
structlog.processors.StackInfoRenderer(),
structlog.processors.format_exc_info,
structlog.processors.UnicodeDecoder(),
Expand Down
Loading