forked from Mirrors/Dispatcharr
Change some celery tasks from info to debug.
This commit is contained in:
parent
d3615e1a66
commit
24fba3c2b1
4 changed files with 30 additions and 15 deletions
|
|
@ -2,6 +2,7 @@
|
|||
import os
|
||||
from celery import Celery
|
||||
import logging
|
||||
from django.conf import settings # Import Django settings
|
||||
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'dispatcharr.settings')
|
||||
app = Celery("dispatcharr")
|
||||
|
|
@ -10,19 +11,33 @@ app.autodiscover_tasks()
|
|||
|
||||
# Configure Celery logging
|
||||
app.conf.update(
|
||||
worker_log_level='DEBUG',
|
||||
worker_log_level=settings.LOG_LEVEL_NAME, # Use same log level from environment
|
||||
worker_log_format='%(asctime)s %(levelname)s %(name)s: %(message)s',
|
||||
beat_log_level='DEBUG',
|
||||
beat_log_level=settings.LOG_LEVEL_NAME, # Use same log level from environment
|
||||
worker_hijack_root_logger=False,
|
||||
worker_task_log_format='%(asctime)s %(levelname)s %(task_name)s: %(message)s',
|
||||
)
|
||||
|
||||
# Set only specific log messages to DEBUG level
|
||||
# This maintains user configurability for all other loggers
|
||||
@app.on_after_configure.connect
|
||||
def setup_celery_logging(**kwargs):
|
||||
# Only set specific loggers to DEBUG that handle the routine messages
|
||||
# we want to suppress from INFO level
|
||||
logging.getLogger('celery.beat').getChild('Scheduler').setLevel(logging.DEBUG)
|
||||
logging.getLogger('celery.worker.strategy').setLevel(logging.DEBUG)
|
||||
logging.getLogger('celery.app.trace').setLevel(logging.DEBUG)
|
||||
# Check if user has set logging to INFO level
|
||||
if settings.LOG_LEVEL_NAME.upper() == 'INFO':
|
||||
# Get the specific loggers that output the noisy INFO messages
|
||||
for logger_name in ['celery.app.trace', 'celery.beat', 'celery.worker.strategy', 'celery.beat.Scheduler']:
|
||||
# Create a custom filter to suppress specific messages
|
||||
logger = logging.getLogger(logger_name)
|
||||
|
||||
# Add a custom filter to completely filter out the repetitive messages
|
||||
class SuppressFilter(logging.Filter):
|
||||
def filter(self, record):
|
||||
# Return False to completely suppress these specific patterns when at INFO level
|
||||
if (
|
||||
"succeeded in" in getattr(record, 'msg', '') or
|
||||
"Scheduler: Sending due task" in getattr(record, 'msg', '') or
|
||||
"received" in getattr(record, 'msg', '')
|
||||
):
|
||||
return False # Don't log these messages at all
|
||||
return True # Log all other messages
|
||||
|
||||
# Add the filter to each logger
|
||||
logger.addFilter(SuppressFilter())
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ exec-before = python /app/scripts/wait_for_redis.py
|
|||
; Start Redis first
|
||||
attach-daemon = redis-server
|
||||
; Then start other services
|
||||
attach-daemon = celery -A dispatcharr worker -l debug
|
||||
attach-daemon = celery -A dispatcharr beat -l debug
|
||||
attach-daemon = celery -A dispatcharr worker
|
||||
attach-daemon = celery -A dispatcharr beat
|
||||
attach-daemon = daphne -b 0.0.0.0 -p 8001 dispatcharr.asgi:application
|
||||
attach-daemon = cd /app/frontend && npm run dev
|
||||
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ exec-pre = python /app/scripts/wait_for_redis.py
|
|||
; Start Redis first
|
||||
attach-daemon = redis-server
|
||||
; Then start other services
|
||||
attach-daemon = celery -A dispatcharr worker -l debug --concurrency=4
|
||||
attach-daemon = celery -A dispatcharr beat -l debug
|
||||
attach-daemon = celery -A dispatcharr worker --concurrency=4
|
||||
attach-daemon = celery -A dispatcharr beat
|
||||
attach-daemon = daphne -b 0.0.0.0 -p 8001 dispatcharr.asgi:application
|
||||
attach-daemon = cd /app/frontend && npm run dev
|
||||
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ exec-pre = python /app/scripts/wait_for_redis.py
|
|||
; Start Redis first
|
||||
attach-daemon = redis-server
|
||||
; Then start other services
|
||||
attach-daemon = celery -A dispatcharr worker -l info --concurrency=4
|
||||
attach-daemon = celery -A dispatcharr beat -l error
|
||||
attach-daemon = celery -A dispatcharr worker --concurrency=4
|
||||
attach-daemon = celery -A dispatcharr beat
|
||||
attach-daemon = daphne -b 0.0.0.0 -p 8001 dispatcharr.asgi:application
|
||||
|
||||
# Core settings
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue