Merge "Add option to disable color"
This commit is contained in:
commit
9bee2820a2
@ -118,6 +118,11 @@ generic_log_opts = [
|
||||
deprecated_for_removal=True,
|
||||
deprecated_reason='Windows support is no longer maintained.',
|
||||
help='Log output to Windows Event Log.'),
|
||||
cfg.BoolOpt('log_color',
|
||||
default=False,
|
||||
help='(Optional) Set the \'color\' key according to log '
|
||||
'levels. This option takes effect only when logging '
|
||||
'to stderr or stdout is used. ' + _IGNORE_MESSAGE),
|
||||
cfg.IntOpt('log_rotate_interval',
|
||||
default=1,
|
||||
help='The amount of time before the log files are rotated. '
|
||||
|
@ -405,7 +405,10 @@ def _setup_logging_from_conf(conf, project, version):
|
||||
log_root.addHandler(filelog)
|
||||
|
||||
if conf.use_stderr:
|
||||
streamlog = handlers.ColorHandler()
|
||||
if conf.log_color:
|
||||
streamlog = handlers.ColorHandler()
|
||||
else:
|
||||
streamlog = logging.StreamHandler()
|
||||
log_root.addHandler(streamlog)
|
||||
|
||||
if conf.use_journal:
|
||||
@ -425,9 +428,10 @@ def _setup_logging_from_conf(conf, project, version):
|
||||
|
||||
# if None of the above are True, then fall back to standard out
|
||||
if not logpath and not conf.use_stderr and not conf.use_journal:
|
||||
# pass sys.stdout as a positional argument
|
||||
# python2.6 calls the argument strm, in 2.7 it's stream
|
||||
streamlog = handlers.ColorHandler(sys.stdout)
|
||||
if conf.log_color:
|
||||
streamlog = handlers.ColorHandler(sys.stdout)
|
||||
else:
|
||||
streamlog = logging.StreamHandler(sys.stdout)
|
||||
log_root.addHandler(streamlog)
|
||||
|
||||
if conf.publish_errors:
|
||||
|
5
releasenotes/notes/log_color-531437cab4477bcb.yaml
Normal file
5
releasenotes/notes/log_color-531437cab4477bcb.yaml
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
The new ``log_color`` option has been added. When this option is set to
|
||||
``False``, color keys are not set.
|
Loading…
x
Reference in New Issue
Block a user