Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set global logging configuration from a Paste config. #809

Merged
merged 1 commit into from
Jul 26, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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