Automated Action acf2757384 Fix Supervisor startup errors and improve application resilience
- Update database path configuration for better compatibility
- Add comprehensive logging system with error handling
- Create supervisord.conf with proper configuration
- Add environment variable example file
- Enhance health check endpoint to report database status
- Add detailed startup and shutdown event handlers
- Update documentation with troubleshooting information
- Update requirements with additional helpful packages
2025-06-02 22:42:07 +00:00

39 lines
1003 B
Python

import logging
import sys
from pydantic import BaseModel
class LogConfig(BaseModel):
"""Logging configuration to be set for the server"""
LOGGER_NAME: str = "blogging_api"
LOG_FORMAT: str = "%(levelprefix)s | %(asctime)s | %(message)s"
LOG_LEVEL: str = "INFO"
# Logging config
version: int = 1
disable_existing_loggers: bool = False
formatters: dict = {
"default": {
"()": "uvicorn.logging.DefaultFormatter",
"fmt": LOG_FORMAT,
"datefmt": "%Y-%m-%d %H:%M:%S",
},
}
handlers: dict = {
"default": {
"formatter": "default",
"class": "logging.StreamHandler",
"stream": sys.stderr,
},
}
loggers: dict = {
LOGGER_NAME: {"handlers": ["default"], "level": LOG_LEVEL},
}
def get_logger(name: str = None) -> logging.Logger:
"""Get logger with the given name"""
name = name or LogConfig().LOGGER_NAME
return logging.getLogger(name)