[pyramid] Let logging be configured through .ini file
We do not initialize logging in CubicWebPyramidConfiguration thus
preventing logging to be started with cubicweb's configuration. On the
other hand, any logging configuration defined in ``development.ini``
file will be loaded by whatever start the instance using this file (i.e.
pserve, gunicorn, etc.). The benefit is that logging can now be
configured per "qualified name" in this file (i.e. one can easily set
the DEBUG level for the application cube while keeping all dependencies'
level to WARNING). In the development.ini template, we add logger
configurations for "logilab" and "cubicweb" qualified names (along with
those of the application cube).
--- a/cubicweb/pyramid/config.py Fri Dec 01 11:19:19 2017 +0100
+++ b/cubicweb/pyramid/config.py Tue Dec 12 11:17:25 2017 +0100
@@ -47,6 +47,11 @@
options = merge_options(ServerConfiguration.options +
BaseWebConfiguration.options)
+ def init_log(self, *args, **kwargs):
+ """Rely on logging configuration in Pyramid's .ini file, do nothing
+ here.
+ """
+
def write_development_ini(self, cubes):
"""Write a 'development.ini' file into apphome."""
template_fpath = path.join(path.dirname(__file__), 'development.ini.tmpl')
--- a/cubicweb/pyramid/development.ini.tmpl Fri Dec 01 11:19:19 2017 +0100
+++ b/cubicweb/pyramid/development.ini.tmpl Tue Dec 12 11:17:25 2017 +0100
@@ -37,3 +37,47 @@
[server:main]
use = egg:waitress#main
listen = 127.0.0.1:6543 [::1]:6543
+
+###
+# logging configuration
+# https://docs.pylonsproject.org/projects/pyramid/en/latest/narr/logging.html
+###
+
+[loggers]
+keys = root, logilab, cubicweb, cubicweb_%(cubename)s
+
+[handlers]
+keys = console
+
+[formatters]
+keys = generic
+
+[logger_root]
+level = INFO
+handlers = console
+
+[logger_logilab]
+level = WARNING
+handlers = console
+qualname = logilab
+
+[logger_cubicweb]
+level = INFO
+handlers = console
+qualname = cubicweb
+
+[logger_cubicweb_%(cubename)s]
+level = DEBUG
+handlers = console
+qualname = cubicweb_%(cubename)s
+
+[handler_console]
+class = StreamHandler
+args = (sys.stderr,)
+level = NOTSET
+formatter = generic
+
+[formatter_generic]
+class = logilab.common.logging_ext.ColorFormatter
+format = %%(asctime)s - (%%(name)s) %%(levelname)s: %%(message)s
+datefmt = %%Y-%%m-%%d %%H:%%M:%%S
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/doc/changes/3.26.rst Tue Dec 12 11:17:25 2017 +0100
@@ -0,0 +1,9 @@
+3.26 (unreleased)
+=================
+
+New features
+------------
+
+* For ``pyramid`` instance configuration kind, logging is not handled anymore
+ by CubicWeb but should be configured through ``development.ini`` file
+ following https://docs.pylonsproject.org/projects/pyramid/en/latest/narr/logging.html.