Skip to content

Commit

Permalink
Merge pull request #809 from berkerpeksag/set-logging-paste
Browse files Browse the repository at this point in the history
Set global logging configuration from a Paste config.
  • Loading branch information
benoitc committed Jul 26, 2014
2 parents bcb3c00 + b6d445a commit 7bb1a57
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions gunicorn/app/pasterapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@
from gunicorn import util


def _configure_logging_from_paste_config(paste_file):
logger_cfg_file = paste_file.split(':')[1]
cfg_parser = ConfigParser.ConfigParser()
cfg_parser.read([logger_cfg_file])
if cfg_parser.has_section('loggers'):
from logging.config import fileConfig
config_file = os.path.abspath(logger_cfg_file)
fileConfig(config_file, dict(__file__=config_file,
here=os.path.dirname(config_file)))


def paste_config(gconfig, config_url, relative_to, global_conf=None):
# add entry to pkg_resources
sys.path.insert(0, relative_to)
Expand All @@ -41,6 +52,9 @@ def paste_config(gconfig, config_url, relative_to, global_conf=None):
cfg['umask'] = int(lc.get('umask', 0))
cfg['default_proc_name'] = gc.get('__file__')

# init logging configuration
_configure_logging_from_paste_config(config_url)

for k, v in gc.items():
if k not in gconfig.settings:
continue
Expand Down

0 comments on commit 7bb1a57

Please sign in to comment.