X-Git-Url: https://gerrit.fd.io/r/gitweb?p=csit.git;a=blobdiff_plain;f=resources%2Flibraries%2Fpython%2FFilteredLogger.py;h=42068ef58cd5bbe736099f82c0bc9726e4256e01;hp=a04eb674761c7dd55e26e0667cd88fa69280895f;hb=7829fea4a2c8936513fa95215b7d84997f814a69;hpb=f88a3d9178dfbd73d0479f9aa2f5224e0c89ca1f diff --git a/resources/libraries/python/FilteredLogger.py b/resources/libraries/python/FilteredLogger.py index a04eb67476..42068ef58c 100644 --- a/resources/libraries/python/FilteredLogger.py +++ b/resources/libraries/python/FilteredLogger.py @@ -1,4 +1,4 @@ -# Copyright (c) 2019 Cisco and/or its affiliates. +# Copyright (c) 2021 Cisco and/or its affiliates. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at: @@ -26,17 +26,18 @@ Logger.console() is not supported. import logging _LEVELS = { - "TRACE": logging.DEBUG // 2, - "DEBUG": logging.DEBUG, - "INFO": logging.INFO, - "HTML": logging.INFO, - "WARN": logging.WARN, - "ERROR": logging.ERROR, - "CRITICAL": logging.CRITICAL, - "NONE": logging.CRITICAL, + u"TRACE": logging.DEBUG // 2, + u"DEBUG": logging.DEBUG, + u"INFO": logging.INFO, + u"HTML": logging.INFO, + u"WARN": logging.WARN, + u"ERROR": logging.ERROR, + u"CRITICAL": logging.CRITICAL, + u"NONE": logging.CRITICAL, } -class FilteredLogger(object): + +class FilteredLogger: """Instances of this class have the similar API to robot.api.logger. TODO: Support html argument? @@ -57,7 +58,7 @@ class FilteredLogger(object): self.logger_module = logger_module self.min_level_num = _LEVELS[min_level.upper()] - def write(self, message, farg=None, level="INFO"): + def write(self, message, farg=None, level=u"INFO"): """Forwards the message to logger if min_level is reached. Formatting using '%' operator is used when farg argument is suplied. @@ -76,20 +77,20 @@ class FilteredLogger(object): def trace(self, message, farg=None): """Forward the message using the ``TRACE`` level.""" - self.write(message, farg=farg, level="TRACE") + self.write(message, farg=farg, level=u"TRACE") def debug(self, message, farg=None): """Forward the message using the ``DEBUG`` level.""" - self.write(message, farg=farg, level="DEBUG") + self.write(message, farg=farg, level=u"DEBUG") def info(self, message, farg=None): """Forward the message using the ``INFO`` level.""" - self.write(message, farg=farg, level="INFO") + self.write(message, farg=farg, level=u"INFO") def warn(self, message, farg=None): """Forward the message using the ``WARN`` level.""" - self.write(message, farg=farg, level="WARN") + self.write(message, farg=farg, level=u"WARN") def error(self, message, farg=None): """Forward the message using the ``ERROR`` level.""" - self.write(message, farg=farg, level="ERROR") + self.write(message, farg=farg, level=u"ERROR")