fix logging statement uses 'warn' instead of 'warning'

This commit is contained in:
Robert Kaussow 2022-08-21 23:29:20 +02:00
parent 03b25e86af
commit eb58640375
Signed by: xoxys
GPG Key ID: 4E692A2EAECC03C0
2 changed files with 12 additions and 9 deletions

View File

@ -62,11 +62,11 @@ class MultilineJsonFormatter(jsonlogger.JsonFormatter):
class Log:
"""Base logging object."""
def __init__(self, level=logging.WARN, name="ansibledoctor", json=False):
def __init__(self, level=logging.WARNING, name="ansibledoctor", json=False):
self.logger = logging.getLogger(name)
self.logger.setLevel(level)
self.logger.addHandler(self._get_error_handler(json=json))
self.logger.addHandler(self._get_warn_handler(json=json))
self.logger.addHandler(self._get_warning_handler(json=json))
self.logger.addHandler(self._get_info_handler(json=json))
self.logger.addHandler(self._get_critical_handler(json=json))
self.logger.addHandler(self._get_debug_handler(json=json))
@ -87,13 +87,15 @@ class Log:
return handler
def _get_warn_handler(self, json=False):
def _get_warning_handler(self, json=False):
handler = logging.StreamHandler(sys.stdout)
handler.setLevel(logging.WARN)
handler.addFilter(LogFilter(logging.WARN))
handler.setLevel(logging.WARNING)
handler.addFilter(LogFilter(logging.WARNING))
handler.setFormatter(
MultilineFormatter(
self.warn(CONSOLE_FORMAT.format(colorama.Fore.YELLOW, colorama.Style.RESET_ALL))
self.warning(
CONSOLE_FORMAT.format(colorama.Fore.YELLOW, colorama.Style.RESET_ALL)
)
)
)
@ -162,8 +164,8 @@ class Log:
"""Format error messages and return string."""
return msg
def warn(self, msg):
"""Format warn messages and return string."""
def warning(self, msg):
"""Format warning messages and return string."""
return msg
def info(self, msg):

View File

@ -7,8 +7,9 @@
# D107: Missing docstring in __init__
# D202: No blank lines allowed after function docstring
# G001: Logging statements should not use string.format() for their first argument
# G004: Logging statements should not use f"..." for their first argument
# W503: Line break occurred before a binary operator
ignore = D102, D103, D105, D107, D202, G001, W503
ignore = D102, D103, D105, D107, D202, G001, G004, W503
max-line-length = 99
inline-quotes = double
exclude = .git, __pycache__, build, dist, test, *.pyc, *.egg-info, .cache, .eggs, env*