Use number of verbose flag as log level

It decouples the logging level from the development mode.

issue8026
review66521002
This commit is contained in:
Cédric Krier committed 2019-02-05 19:27:10 +01:00
1 parent 0d15afb90e
commit ddf9e44dbe
3 files changed
+5 -11

No files matched your search

+1
View File
@@ -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
+1 -2
View File
@@ -5,8 +5,7 @@ Logging configuration
=====================
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.
+3 -9
View File
@@ -20,8 +20,8 @@ def get_parser():
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 @@ def config_log(options):
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)