Commit 08e12c08 authored by Jérome Perrin's avatar Jérome Perrin

zopewsgi: setup logging before loading ZConfig

Loading ZConfig will initialize storage and generally might do things
that will cause messages to be emitted.
One actual problem is with neo storage, which configure root logger
when it's not already configured [1], this was causing all logged
messages to be logged in the console when using neo storage.

1: https://lab.nexedi.com/nexedi/neoppod/blob/fd87e153/neo/lib/logger.py#L63-64
parent d496e223
......@@ -184,13 +184,6 @@ def runwsgi():
default=type_registry.get('byte-size')("10MB"))
args = parser.parse_args()
startup = os.path.dirname(Zope2.Startup.__file__)
if os.path.isfile(os.path.join(startup, 'wsgischema.xml')):
schema = ZConfig.loadSchema(os.path.join(startup, 'wsgischema.xml'))
else: # BBB Zope2
schema = ZConfig.loadSchema(os.path.join(startup, 'zopeschema.xml'))
conf, _ = ZConfig.loadConfig(schema, args.zope_conf)
# Configure logging previously handled by ZConfig/ZServer
logging.captureWarnings(True)
root_logger = logging.getLogger()
......@@ -221,6 +214,13 @@ def runwsgi():
LongRequestLogger_dumper.logger.propagate = False
LongRequestLogger_dumper.logger.addHandler(long_request_log_handler)
startup = os.path.dirname(Zope2.Startup.__file__)
if os.path.isfile(os.path.join(startup, 'wsgischema.xml')):
schema = ZConfig.loadSchema(os.path.join(startup, 'wsgischema.xml'))
else: # BBB Zope2
schema = ZConfig.loadSchema(os.path.join(startup, 'zopeschema.xml'))
conf, _ = ZConfig.loadConfig(schema, args.zope_conf)
if conf.debug_mode:
console_handler = logging.StreamHandler(sys.stderr)
console_handler.setFormatter(logging.Formatter(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment