changeset 43d0e1e1f44b in trytond:default details: https://hg.tryton.org/trytond?cmd=changeset;node=43d0e1e1f44b description: Use number of verbose flag as log level
It decouples the logging level from the development mode. issue8026 review66521002 diffstat: CHANGELOG | 1 + doc/topics/logs.rst | 3 +-- trytond/commandline.py | 12 +++--------- 3 files changed, 5 insertions(+), 11 deletions(-) diffs (50 lines): diff -r f49e2e7fc2e6 -r 43d0e1e1f44b CHANGELOG --- a/CHANGELOG Tue Feb 05 19:09:53 2019 +0100 +++ b/CHANGELOG Tue Feb 05 19:27:10 2019 +0100 @@ -1,3 +1,4 @@ +* Use number of verbose flag as log level * Add coroutine concurrency option * Add increasing delay on database operational error retry * Allows to lock records for update diff -r f49e2e7fc2e6 -r 43d0e1e1f44b doc/topics/logs.rst --- a/doc/topics/logs.rst Tue Feb 05 19:09:53 2019 +0100 +++ b/doc/topics/logs.rst Tue Feb 05 19:27:10 2019 +0100 @@ -5,8 +5,7 @@ ===================== Without any configuration, trytond writes ERROR messages to standard output. -With the verbose flag set, it writes INFO message. -And with the verbose and development flags set, it write DEBUG message. +For each verbose flag set, the log level decreases. Logs can be configured using a `configparser-format`_ file. The filename can be specified using trytond ``logconf`` parameter. diff -r f49e2e7fc2e6 -r 43d0e1e1f44b trytond/commandline.py --- a/trytond/commandline.py Tue Feb 05 19:09:53 2019 +0100 +++ b/trytond/commandline.py Tue Feb 05 19:27:10 2019 +0100 @@ -20,8 +20,8 @@ parser.add_argument("-c", "--config", dest="configfile", metavar='FILE', nargs='+', default=[os.environ.get('TRYTOND_CONFIG')], help='Specify configuration files') - parser.add_argument("-v", "--verbose", action="store_true", - dest="verbose", help="enable verbose mode") + parser.add_argument("-v", "--verbose", action='count', + dest="verbose", default=0, help="enable verbose mode") parser.add_argument('--dev', dest='dev', action='store_true', help='enable development mode') @@ -96,13 +96,7 @@ else: logformat = ('%(process)s %(thread)s [%(asctime)s] ' '%(levelname)s %(name)s %(message)s') - if options.verbose: - if options.dev: - level = logging.DEBUG - else: - level = logging.INFO - else: - level = logging.ERROR + level = max(logging.ERROR - options.verbose * 10, logging.NOTSET) logging.basicConfig(level=level, format=logformat) logging.captureWarnings(True)