| 123456789101112131415161718192021222324252627282930 |
- import logging
- from logging.config import dictConfig
- def setup_logging(app):
- """Configure basic logging for the application."""
- level = logging.DEBUG if app.config.get("DEBUG") else logging.INFO
- config = {
- "version": 1,
- "disable_existing_loggers": False,
- "formatters": {
- "default": {
- "format": "%(asctime)s %(levelname)s %(name)s: %(message)s",
- }
- },
- "handlers": {
- "console": {
- "class": "logging.StreamHandler",
- "formatter": "default",
- "level": level,
- }
- },
- "root": {
- "handlers": ["console"],
- "level": level,
- },
- }
- dictConfig(config)
|