slightly rework of the log output formatting

This commit is contained in:
Robert Kaussow 2020-04-05 15:24:51 +02:00
parent dc0af76559
commit e1ff6d2e73
2 changed files with 10 additions and 8 deletions

View File

@ -1,3 +1,3 @@
* BUGFIX
* replace removed dependency `ansible.module_utils.parsing.convert_bool`
* decode task actions to prevent errors on multiline strings
* ENHANCEMENT
* improve ANSIBLE0001 logic to avoid false positive results
* improve log output readability

View File

@ -9,7 +9,7 @@ import colorama
from pythonjsonlogger import jsonlogger
from six import iteritems
CONSOLE_FORMAT = "%(levelname)s: %(message)s"
CONSOLE_FORMAT = "%(levelname)s: {}%(message)s"
JSON_FORMAT = "(asctime) (levelname) (message)"
@ -63,6 +63,7 @@ class MultilineFormatter(logging.Formatter):
def format(self, record): # noqa
record.msg = record.msg.replace("\n", "\n{}... ".format(colorama.Style.RESET_ALL))
record.msg = record.msg + "\n"
return logging.Formatter.format(self, record)
@ -157,22 +158,22 @@ def _get_critical_handler(json=False):
def critical(message):
"""Format critical messages and return string."""
return color_text(colorama.Fore.RED, "{}".format(message))
return color_text(colorama.Fore.RED, message)
def error(message):
"""Format error messages and return string."""
return color_text(colorama.Fore.RED, "{}".format(message))
return color_text(colorama.Fore.RED, message)
def warn(message):
"""Format warn messages and return string."""
return color_text(colorama.Fore.YELLOW, "{}".format(message))
return color_text(colorama.Fore.YELLOW, message)
def info(message):
"""Format info messages and return string."""
return color_text(colorama.Fore.BLUE, "{}".format(message))
return color_text(colorama.Fore.BLUE, message)
def color_text(color, msg):
@ -184,4 +185,5 @@ def color_text(color, msg):
:returns: string
"""
msg = msg.format(colorama.Style.BRIGHT)
return "{}{}{}".format(color, msg, colorama.Style.RESET_ALL)