# HG changeset patch # User Laurent Peuch # Date 1566333946 -7200 # Node ID a54037a68b144497440852eddd80708b1a57a9d7 # Parent 56f7386bc6b9c88f3e48f97241526af29cef8c05 [logging] send logs by default to stdout Following the move to have commands only working on foreground sending logs to a file by default doesn't make much more sens anymore so send them to stdout by default and add a new option to send them to a file if needed diff -r 56f7386bc6b9 -r a54037a68b14 cubicweb/cwconfig.py --- a/cubicweb/cwconfig.py Tue May 21 18:16:51 2019 +0200 +++ b/cubicweb/cwconfig.py Tue Aug 20 22:45:46 2019 +0200 @@ -626,7 +626,7 @@ cubicweb_appobject_path = set(['entities']) cube_appobject_path = set(['entities']) - def __init__(self, debugmode=False): + def __init__(self, debugmode=False, log_to_file=False): if debugmode: # in python 2.7, DeprecationWarning are not shown anymore by default filterwarnings('default', category=DeprecationWarning) @@ -634,6 +634,7 @@ self._cubes = None super(CubicWebNoAppConfiguration, self).__init__() self.debugmode = debugmode + self.log_to_file = log_to_file self.adjust_sys_path() self.load_defaults() # will be properly initialized later by _gettext_init @@ -664,12 +665,12 @@ # no logrotate on win32, so use logging rotation facilities # for now, hard code weekly rotation every sunday, and 52 weeks kept # idea: make this configurable? - init_log(self.debugmode, syslog, logthreshold, logfile, self.log_format, + init_log(not self.log_to_file, syslog, logthreshold, logfile, self.log_format, rotation_parameters={'when': 'W6', # every sunday 'interval': 1, 'backupCount': 52}) else: - init_log(self.debugmode, syslog, logthreshold, logfile, self.log_format) + init_log(not self.log_to_file, syslog, logthreshold, logfile, self.log_format) # configure simpleTal logger logging.getLogger('simpleTAL').setLevel(logging.ERROR) @@ -882,13 +883,13 @@ return mdir @classmethod - def config_for(cls, appid, config=None, debugmode=False, creating=False): + def config_for(cls, appid, config=None, debugmode=False, log_to_file=False, creating=False): """return a configuration instance for the given instance identifier """ cls.load_available_configs() config = config or guess_configuration(cls.instance_home(appid)) configcls = configuration_cls(config) - return configcls(appid, debugmode, creating) + return configcls(appid, debugmode, creating, log_to_file=log_to_file) @classmethod def possible_configurations(cls, appid): @@ -981,11 +982,12 @@ # instance methods used to get instance specific resources ############# - def __init__(self, appid, debugmode=False, creating=False): + def __init__(self, appid, debugmode=False, creating=False, log_to_file=False): self.appid = appid # set to true while creating an instance self.creating = creating - super(CubicWebConfiguration, self).__init__(debugmode) + super(CubicWebConfiguration, self).__init__(debugmode, + log_to_file=log_to_file) fake_gettext = (str, lambda ctx, msgid: str(msgid)) for lang in self.available_languages(): self.translations[lang] = fake_gettext diff -r 56f7386bc6b9 -r a54037a68b14 doc/changes/3.27.rst --- a/doc/changes/3.27.rst Tue May 21 18:16:51 2019 +0200 +++ b/doc/changes/3.27.rst Tue Aug 20 22:45:46 2019 +0200 @@ -23,6 +23,10 @@ * the --loglevel and --dbglevel flags are available for all cubicweb-ctl instance commands (and not only the ``pyramid`` one) +* following "only in foreground" behavior all commands logs to stdout by + default from now on. To still log to a file pass ``log_to_file=True`` to + ``CubicWebConfiguration.config_for`` + Backwards incompatible changes ------------------------------