mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
Issue 1087: support dictConfig logging configuration
This commit is contained in:
parent
ccad26dd91
commit
e6de1a07b4
@ -1309,6 +1309,19 @@ class LogConfig(Setting):
|
||||
"""
|
||||
|
||||
|
||||
class LogConfigDict(Setting):
|
||||
name = "logconfig_dict"
|
||||
section = "Logging"
|
||||
validator = validate_dict
|
||||
default = {}
|
||||
desc = """\
|
||||
The log config dictionary to use, using the standard Python logging
|
||||
module's dictConfig format.
|
||||
If specified, this takes precedence over logconfig, which uses the older
|
||||
fileConfig format.
|
||||
"""
|
||||
|
||||
|
||||
class SyslogTo(Setting):
|
||||
name = "syslog_addr"
|
||||
section = "Logging"
|
||||
|
||||
@ -8,7 +8,7 @@ import binascii
|
||||
import time
|
||||
import logging
|
||||
logging.Logger.manager.emittedNoHandlerWarning = 1
|
||||
from logging.config import fileConfig
|
||||
from logging.config import fileConfig, dictConfig
|
||||
import os
|
||||
import socket
|
||||
import sys
|
||||
@ -226,7 +226,11 @@ class Logger(object):
|
||||
self.access_log, cfg, self.syslog_fmt, "access"
|
||||
)
|
||||
|
||||
if cfg.logconfig:
|
||||
if cfg.logconfig_dict:
|
||||
config = CONFIG_DEFAULTS.copy()
|
||||
config.update(cfg.logconfig_dict)
|
||||
dictConfig(config)
|
||||
elif cfg.logconfig:
|
||||
if os.path.exists(cfg.logconfig):
|
||||
defaults = CONFIG_DEFAULTS.copy()
|
||||
defaults['__file__'] = cfg.logconfig
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user