Skip to content

Commit

Permalink
Merge pull request #87 from maykinmedia/bug/fix-celery-logging
Browse files Browse the repository at this point in the history
🔊 add celery logging
  • Loading branch information
Coperh authored Dec 16, 2024
2 parents 05f58c4 + 66d5013 commit 6b5f41f
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion open_api_framework/conf/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@
# LOGGING
#
LOG_STDOUT = config(
"LOG_STDOUT", default=False, help_text="whether to log to stdout or not"
"LOG_STDOUT", default=True, help_text="whether to log to stdout or not"
)
LOG_LEVEL = config(
"LOG_LEVEL",
Expand All @@ -377,6 +377,13 @@
RuntimeWarning,
)

CELERY_LOGLEVEL = config(
"CELERY_LOGLEVEL",
default="INFO",
help_text="control the verbosity of logging output for celery, independent of ``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",
},
"celery_console": {
"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 @@ -507,6 +527,11 @@
"level": "DEBUG",
"propagate": True,
},
"celery": {
"handlers": ["celery_console"] if LOG_STDOUT else ["celery_file"],
"level": CELERY_LOGLEVEL,
"propagate": True,
},
},
}

Expand Down

0 comments on commit 6b5f41f

Please sign in to comment.