Setup default logging for WSGI application

issue8510
review263911003
This commit is contained in:
Cédric Krier committed 2019-07-23 00:09:25 +02:00
1 parent d00e1bb00a
commit e703f3f048
3 files changed
+13

No files matched your search

+1
View File
@@ -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
+4
View File
@@ -26,12 +26,16 @@ Following environment variables can be set:
* `TRYTOND_CONFIG`: Point to :ref:`configuration <topics-configuration>` file.
* `TRYTOND_LOGGING_CONFIG`: Point to :ref:`logging <topics-logs>` 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`: <https://docs.python.org/library/logging.html#logging-levels>`.
Coroutine server
----------------
+8
View File
@@ -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