https://github.com/beda-software/aidbox-logging-py
Aidbox $loggy python logging
https://github.com/beda-software/aidbox-logging-py
Last synced: 9 months ago
JSON representation
Aidbox $loggy python logging
- Host: GitHub
- URL: https://github.com/beda-software/aidbox-logging-py
- Owner: beda-software
- License: mit
- Created: 2024-12-19T20:47:54.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-19T23:21:38.000Z (over 1 year ago)
- Last Synced: 2025-08-05T07:46:24.656Z (10 months ago)
- Language: Python
- Size: 57.6 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
[](https://github.com/beda-software/aidbox-logging-py/actions/workflows/main.yml)
[](https://codecov.io/gh/beda-software/aidbox-logging-py)
[](https://pypi.org/project/aidbox-logging)
[](https://mypy-lang.org/)
[](https://www.python.org/downloads/release/python-311/)
# aidbox-logging-py
Aidbox $loggy python logging handler with queue
## Installation
Install from pypi as `aidbox-logging`
## Usage
```python
from aidbox_logging import init_queued_aidbox_loggy_handler, enable_excepthook_logging
logging.basicConfig(
format="[%(asctime)s] [%(process)d] [%(levelname)s] %(name)s %(message)s",
datefmt="%Y-%m-%d %H:%M:%S %z",
)
root_logger = logging.getLogger()
root_logger.setLevel(logging.DEBUG)
if env_config.loggy_url:
loggy_handler = init_queued_aidbox_loggy_handler(
env_config.loggy_url,
app="lab-backend",
version=f"{version.__version__}-{version.__build_commit_hash__}",
meta={
"env": env_config.lab_room_id,
},
)
# By default all log messages will be handled by loggy
root_logger.addHandler(loggy_handler)
# By default gunicorn errors are not propagated, so we handle it explicitly
logging.getLogger("gunicorn.error").addHandler(loggy_handler)
# Optional: enable excepthook logging that intercepts all exceptions inside threads
enable_excepthook_logging()
```