mirror of
https://github.com/thegeeklab/ansible-later.git
synced 2024-06-13 13:50:57 +02:00
slightly rework of the log output formatting
This commit is contained in:
parent
dc0af76559
commit
e1ff6d2e73
|
@ -1,3 +1,3 @@
|
||||||
* BUGFIX
|
* ENHANCEMENT
|
||||||
* replace removed dependency `ansible.module_utils.parsing.convert_bool`
|
* improve ANSIBLE0001 logic to avoid false positive results
|
||||||
* decode task actions to prevent errors on multiline strings
|
* improve log output readability
|
||||||
|
|
|
@ -9,7 +9,7 @@ import colorama
|
||||||
from pythonjsonlogger import jsonlogger
|
from pythonjsonlogger import jsonlogger
|
||||||
from six import iteritems
|
from six import iteritems
|
||||||
|
|
||||||
CONSOLE_FORMAT = "%(levelname)s: %(message)s"
|
CONSOLE_FORMAT = "%(levelname)s: {}%(message)s"
|
||||||
JSON_FORMAT = "(asctime) (levelname) (message)"
|
JSON_FORMAT = "(asctime) (levelname) (message)"
|
||||||
|
|
||||||
|
|
||||||
|
@ -63,6 +63,7 @@ class MultilineFormatter(logging.Formatter):
|
||||||
|
|
||||||
def format(self, record): # noqa
|
def format(self, record): # noqa
|
||||||
record.msg = record.msg.replace("\n", "\n{}... ".format(colorama.Style.RESET_ALL))
|
record.msg = record.msg.replace("\n", "\n{}... ".format(colorama.Style.RESET_ALL))
|
||||||
|
record.msg = record.msg + "\n"
|
||||||
return logging.Formatter.format(self, record)
|
return logging.Formatter.format(self, record)
|
||||||
|
|
||||||
|
|
||||||
|
@ -157,22 +158,22 @@ def _get_critical_handler(json=False):
|
||||||
|
|
||||||
def critical(message):
|
def critical(message):
|
||||||
"""Format critical messages and return string."""
|
"""Format critical messages and return string."""
|
||||||
return color_text(colorama.Fore.RED, "{}".format(message))
|
return color_text(colorama.Fore.RED, message)
|
||||||
|
|
||||||
|
|
||||||
def error(message):
|
def error(message):
|
||||||
"""Format error messages and return string."""
|
"""Format error messages and return string."""
|
||||||
return color_text(colorama.Fore.RED, "{}".format(message))
|
return color_text(colorama.Fore.RED, message)
|
||||||
|
|
||||||
|
|
||||||
def warn(message):
|
def warn(message):
|
||||||
"""Format warn messages and return string."""
|
"""Format warn messages and return string."""
|
||||||
return color_text(colorama.Fore.YELLOW, "{}".format(message))
|
return color_text(colorama.Fore.YELLOW, message)
|
||||||
|
|
||||||
|
|
||||||
def info(message):
|
def info(message):
|
||||||
"""Format info messages and return string."""
|
"""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):
|
def color_text(color, msg):
|
||||||
|
@ -184,4 +185,5 @@ def color_text(color, msg):
|
||||||
:returns: string
|
:returns: string
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
msg = msg.format(colorama.Style.BRIGHT)
|
||||||
return "{}{}{}".format(color, msg, colorama.Style.RESET_ALL)
|
return "{}{}{}".format(color, msg, colorama.Style.RESET_ALL)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user