Skip to content

Commit

Permalink
🔊 create separate logger for celery
Browse files Browse the repository at this point in the history
  • Loading branch information
Coperh committed Nov 22, 2024
1 parent 476762c commit ce1ff80
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions open_api_framework/conf/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,13 @@
RuntimeWarning,
)

CELERY_LOGLEVEL = config(
"CELERY_LOGLEVEL",
default="INFO",
help_text="control the verbosity of logging output for celery, separate from ``LOG_LEVEL``."
" Available values are ``CRITICAL``, ``ERROR``, ``WARNING``, ``INFO`` and ``DEBUG``",
)

LOGGING_DIR = Path(BASE_DIR) / "log"

logging_root_handlers = ["console"] if LOG_STDOUT else ["project"]
Expand Down Expand Up @@ -415,6 +422,19 @@
"class": "logging.StreamHandler",
"formatter": "db",
},
"console_celery": {
"level": CELERY_LOGLEVEL,
"class": "logging.StreamHandler",
"formatter": "timestamped",
},
"celery_file": {
"level": CELERY_LOGLEVEL,
"class": "logging.handlers.RotatingFileHandler",
"filename": Path(LOGGING_DIR) / "celery.log",
"formatter": "verbose",
"maxBytes": 1024 * 1024 * 10, # 10 MB
"backupCount": 10,
},
"django": {
"level": LOG_LEVEL,
"class": "logging.handlers.RotatingFileHandler",
Expand Down Expand Up @@ -508,8 +528,8 @@
"propagate": True,
},
"celery": {
"handlers": logging_root_handlers,
"level": LOG_LEVEL,
"handlers": ["console_celery"] if LOG_STDOUT else ["celery_file"],
"level": CELERY_LOGLEVEL,
"propagate": True,
},
},
Expand Down

0 comments on commit ce1ff80

Please sign in to comment.