App Flask, tryton log level

Hi,
I am creating a flask application with flask_tryton.
I can’t find how to modify the tryton log level.
How can we enter the trytond-logconf.conf file as a parameter?

app = Flask(__name__)
app.config['TRYTON_DATABASE'] = 'base'
app.config['TRYTON_CONFIG'] = 'trytond.conf'
app.config['SECRET_KEY'] = 'keyxxxxxxxxxxxxxxxxxxx'

tryton = Tryton(app, configure_jinja=False)

...

if __name__ == "__main__":
    app.run(port=5500, debug=False)

When using trytond as a WSGI server, you can setup using some environment variables like TRYTOND_LOGGING_CONFIG or TRYTOND_LOGGING_LEVEL.

it doesn’t work

trytond-logconf.conf:

[formatters]
keys=simple

[handlers]
keys=rotate,console

[loggers]
keys=root

[formatter_simple]
format=%(asctime)s] %(levelname)s:%(name)s:%(message)s
datefmt=%a %b %d %H:%M:%S %Y

[handler_rotate]
class=handlers.TimedRotatingFileHandler
args=('/tmp/tryton.log', 'D', 1, 30)
formatter=simple

[handler_console]
class=StreamHandler
formatter=simple
args=(sys.stdout,)

[logger_root]
level=ERROR
handlers=rotate,console

To launch the application:

#!/bin/bash

export TRYTOND_LOGGING_CONFIG="/path/to/trytond-logconf.conf"
gunicorn -w 4 -b 127.0.0.1:8080 api:app

log content:

...
INFO:trytond.modules:asp_PartyOther
INFO:trytond.modules:asp_Product
INFO:trytond.modules:asp_Purchase
INFO:trytond.modules:asp_ImportProduct
INFO:trytond.modules:asp_Sale
INFO:trytond.pool:setup pool for "asperpgi8"
DEBUG:trytond.backend.postgresql.database:b'SELECT 1'
DEBUG:trytond.backend.postgresql.database:b'SELECT "provolatile" FROM pg_proc WHERE proname=\'unaccent\''
INFO:trytond.pool:setup mixin for "asperpgi8"
INFO:trytond.pool:setup mixin for "asperpgi8"
DEBUG:trytond.backend.postgresql.database:b'SELECT 1'
DEBUG:trytond.backend.postgresql.database:b'SELECT 1'
INFO:trytond.modules:all modules loaded
INFO:trytond.modules:all modules loaded
DEBUG:trytond.backend.postgresql.database:b'SELECT "a"."id" AS "id", "a"."create_date" AS "create_date", "a"."create_uid" AS "create_uid", "a"."hostname" AS "hostname", "a"."language" AS "language", "a"."product_price_decimal" AS "product_price_decimal", "a"."write_date" AS "write_date", "a"."write_uid" AS "write_uid", CAST(EXTRACT(\'EPOCH\' FROM COALESCE("a"."write_date", "a"."create_date")) AS VARCHAR) AS "_timestamp" FROM "ir_configuration" AS "a" WHERE true ORDER BY "a"."id" ASC LIMIT 1'
...

Maybe there is something to add to the code but I couldn’t find any more information ?

My bad with flask-tryton, trytond is not used as WSGI application.
So you are responsible in your code to setup the logging module.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.