diff --git a/CHANGELOG b/CHANGELOG index 65123f14df..a85926de78 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +* Setup default logging for WSGI app * Add format argument to report format_date function * Change expand attribute into a factor * Allow SQL expression as value of fields diff --git a/doc/topics/start_server.rst b/doc/topics/start_server.rst index 29cc0ea622..bb7c5b66c7 100644 --- a/doc/topics/start_server.rst +++ b/doc/topics/start_server.rst @@ -26,12 +26,16 @@ Following environment variables can be set: * `TRYTOND_CONFIG`: Point to :ref:`configuration ` file. * `TRYTOND_LOGGING_CONFIG`: Point to :ref:`logging ` file. + * `TRYTOND_LOGGING_LEVEL`: An integer to set the default `logging level`_ + (default: `ERROR`). * `TRYTOND_COROUTINE`: Use coroutine for concurrency. * `TRYTOND_DATABASE_NAMES`: A list of database names in CSV format, using python default dialect. .. warning:: You must manage to serve the static files from the web root. +.. _`logging level`: `. + Coroutine server ---------------- diff --git a/trytond/application.py b/trytond/application.py index 0eee1d0532..86e93d55ec 100644 --- a/trytond/application.py +++ b/trytond/application.py @@ -10,8 +10,16 @@ __all__ = ['app'] # Logging must be set before importing logging_config = os.environ.get('TRYTOND_LOGGING_CONFIG') +logging_level = int(os.environ.get( + 'TRYTOND_LOGGING_LEVEL', default=logging.ERROR)) if logging_config: logging.config.fileConfig(logging_config) +else: + logformat = ('%(process)s %(thread)s [%(asctime)s] ' + '%(levelname)s %(name)s %(message)s') + level = max(logging_level, logging.NOTSET) + logging.basicConfig(level=level, format=logformat) +logging.captureWarnings(True) if os.environ.get('TRYTOND_COROUTINE'): from gevent import monkey