diff --git a/open_api_framework/conf/base.py b/open_api_framework/conf/base.py index 2191732..f733f09 100644 --- a/open_api_framework/conf/base.py +++ b/open_api_framework/conf/base.py @@ -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", @@ -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"] @@ -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", @@ -507,6 +527,11 @@ "level": "DEBUG", "propagate": True, }, + "celery": { + "handlers": ["celery_console"] if LOG_STDOUT else ["celery_file"], + "level": CELERY_LOGLEVEL, + "propagate": True, + }, }, }