diff -r 17d1b1f4eddd -r 5add82b08a6d cubicweb/pyramid/pyramidctl.py --- a/cubicweb/pyramid/pyramidctl.py Thu Jul 25 03:33:01 2019 +0200 +++ b/cubicweb/pyramid/pyramidctl.py Tue May 21 18:08:17 2019 +0200 @@ -32,7 +32,8 @@ import threading import subprocess -from cubicweb.cwconfig import CubicWebConfiguration as cwcfg +from logilab.common.configuration import merge_options + from cubicweb.cwctl import CWCTL, InstanceCommand, init_cmdline_log_threshold from cubicweb.pyramid import wsgi_application_from_cwconfig from cubicweb.pyramid.config import get_random_secret_key @@ -45,7 +46,6 @@ MAXFD = 1024 DBG_FLAGS = ('RQL', 'SQL', 'REPO', 'HOOKS', 'OPS', 'SEC', 'MORE') -LOG_LEVELS = ('debug', 'info', 'warning', 'error') def _generate_pyramid_ini_file(pyramid_ini_path): @@ -93,7 +93,7 @@ name = 'pyramid' actionverb = 'started' - options = ( + options = merge_options(( ('debug-mode', {'action': 'store_true', 'help': 'Activate the repository debug mode (' @@ -107,12 +107,6 @@ ('reload-interval', {'type': 'int', 'default': 1, 'help': 'Interval, in seconds, between file modifications checks'}), - ('loglevel', - {'short': 'l', 'type': 'choice', 'metavar': '', - 'default': None, 'choices': LOG_LEVELS, - 'help': 'debug if -D is set, error otherwise; ' - 'one of %s' % (LOG_LEVELS,), - }), ('dbglevel', {'type': 'multiple_choice', 'metavar': '', 'default': None, @@ -140,7 +134,7 @@ 'metavar': 'key1:value1,key2:value2', 'default': {}, 'help': 'override configuration file option with .'}), - ) + ) + InstanceCommand.options) _reloader_environ_key = 'CW_RELOADER_SHOULD_RUN' @@ -245,9 +239,7 @@ autoreload = self['reload'] or self['debug'] - # debugmode=True is to force to have a StreamHandler used instead of - # writting the logs into a file in /tmp - cwconfig = cwcfg.config_for(appid, debugmode=True) + cwconfig = self.cwconfig filelist_path = os.path.join(cwconfig.apphome, '.pyramid-reload-files.list') @@ -269,9 +261,11 @@ filelist_path=filelist_path) if self['dbglevel']: - self['loglevel'] = 'debug' set_debug('|'.join('DBG_' + x.upper() for x in self['dbglevel'])) - init_cmdline_log_threshold(cwconfig, self['loglevel']) + + # if no loglevel is specified and --debug or --dbglevel are here, set log level at debug + if self['loglevel'] is None and (self['debug'] or self['dbglevel']): + init_cmdline_log_threshold(cwconfig, 'debug') app = wsgi_application_from_cwconfig( cwconfig, profile=self['profile'],