django-background-task
django-background-task copied to clipboard
Logging options do nothing if the root logger already has any handlers
You do your logging setup via logging.basicConfig(). As per the python docs: "This function does nothing if the root logger already has handlers configured for it."
So if I have logging configured for django via settings.LOGGING, I can't use the process_tasks logging options to override that. And confusingly, --log-file silently has no effect.
This is really problematic when running under cron if settings.LOGGING includes a stream handler, as you need to silence everything but errors on stdout/stderr to avoid having cron email you non-error output all the time.
Since process_tasks runs in its own process, maybe we should instead remove all handlers and add a file handler if and only if --log-file is provided?
Sounds like a plan.
I should probably review the logging, as I wrote most of it pre-1.3.
Hopefully I'll get a chance at the weekend to do this.