diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..23dc594 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,15 @@ +[project] +name = "lib-uvicorn-config" +version = "0.1.0" +description = "Shared Uvicorn configuration module with logging support" +readme = "README.md" +requires-python = ">=3.10" +authors = [{ name = "Florian Gänsejunge" }] +dependencies = ["simple-logger-handler @ git+https://git.gansejunge.com/notifier/lib-logger-handler.git@main"] + +[build-system] +requires = ["setuptools>=61"] +build-backend = "setuptools.build_meta" + +[project.urls] +Homepage = "https://git.gansejunge.com/notifier/lib-uvicorn-config" diff --git a/uvicorn_logger_config/__init__.py b/uvicorn_logger_config/__init__.py new file mode 100644 index 0000000..599633d --- /dev/null +++ b/uvicorn_logger_config/__init__.py @@ -0,0 +1,3 @@ +from .config import LOGGING_CONFIG, logger + +__all__ = ["LOGGING_CONFIG", "logger"] diff --git a/uvicorn_logger_config/config.py b/uvicorn_logger_config/config.py new file mode 100644 index 0000000..daed735 --- /dev/null +++ b/uvicorn_logger_config/config.py @@ -0,0 +1,25 @@ +from simple_logger_handler import setup_logger + +logger = setup_logger(__name__) + +LOGGING_CONFIG = { + "version": 1, + "disable_existing_loggers": False, + "formatters": { + "default": { + "()": "pythonjsonlogger.jsonlogger.JsonFormatter", + "format": "%(asctime)s %(name)s %(levelname)s %(message)s", + } + }, + "handlers": { + "default": { + "class": "logging.StreamHandler", + "formatter": "default", + "stream": "ext://sys.stdout", + } + }, + "root": { + "level": logger.level, + "handlers": ["default"] + } +}