From 11daffac0d25d22a033d450171d796aa8866c8c9 Mon Sep 17 00:00:00 2001 From: Alec Delaney Date: Sun, 24 Oct 2021 18:42:30 -0400 Subject: [PATCH 1/4] Corrected minor typo --- adafruit_logging.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_logging.py b/adafruit_logging.py index a095315..3f9f1a9 100644 --- a/adafruit_logging.py +++ b/adafruit_logging.py @@ -82,7 +82,7 @@ class PrintHandler(LoggingHandler): """Send logging messages to the console by using print.""" def emit(self, level, msg): - """Send a message to teh console. + """Send a message to the console. :param level: the logging level :param msg: the message to log From ab0d94fd7cf7e96c7d14983b9056584ec01ce54b Mon Sep 17 00:00:00 2001 From: Alec Delaney Date: Sun, 24 Oct 2021 18:47:20 -0400 Subject: [PATCH 2/4] Add typing to functions --- adafruit_logging.py | 46 ++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/adafruit_logging.py b/adafruit_logging.py index 3f9f1a9..1974861 100644 --- a/adafruit_logging.py +++ b/adafruit_logging.py @@ -45,7 +45,7 @@ globals()[name] = value -def level_for(value): +def level_for(value: int) -> str: """Convert a numberic level to the most appropriate name. :param value: a numeric level @@ -62,7 +62,7 @@ def level_for(value): class LoggingHandler: """Abstract logging message handler.""" - def format(self, level, msg): + def format(self, leve: int, msg: str) -> str: """Generate a timestamped message. :param level: the logging level @@ -71,7 +71,7 @@ def format(self, level, msg): """ return "{0}: {1} - {2}".format(time.monotonic(), level_for(level), msg) - def emit(self, level, msg): + def emit(self, level: int, msg: str): """Send a message where it should go. Place holder for subclass implementations. """ @@ -81,7 +81,7 @@ def emit(self, level, msg): class PrintHandler(LoggingHandler): """Send logging messages to the console by using print.""" - def emit(self, level, msg): + def emit(self, level: int, msg: str): """Send a message to the console. :param level: the logging level @@ -98,7 +98,7 @@ def emit(self, level, msg): null_logger = None # pylint:disable=global-statement -def getLogger(name): +def getLogger(name: str) -> 'Logger': """Create or retrieve a logger by name. :param name: the name of the logger to create/retrieve None will cause the @@ -127,7 +127,7 @@ def __init__(self): self._level = NOTSET self._handler = PrintHandler() - def setLevel(self, value): + def setLevel(self, value: int): """Set the logging cuttoff level. :param value: the lowest level to output @@ -135,7 +135,7 @@ def setLevel(self, value): """ self._level = value - def getEffectiveLevel(self): + def getEffectiveLevel(self) -> int: """Get the effective level for this logger. :return: the lowest level to output @@ -143,7 +143,7 @@ def getEffectiveLevel(self): """ return self._level - def addHandler(self, hldr): + def addHandler(self, hldr: LoggingHandler): """Sets the handler of this logger to the specified handler. *NOTE* this is slightly different from the CPython equivalent which adds the handler rather than replaceing it. @@ -153,7 +153,7 @@ def addHandler(self, hldr): """ self._handler = hldr - def log(self, level, format_string, *args): + def log(self, level: int, format_string: str, *args): """Log a message. :param level: the priority level at which to log @@ -164,7 +164,7 @@ def log(self, level, format_string, *args): if level >= self._level: self._handler.emit(level, format_string % args) - def debug(self, format_string, *args): + def debug(self, format_string: str, *args): """Log a debug message. :param format_string: the core message string with embedded formatting directives @@ -173,7 +173,7 @@ def debug(self, format_string, *args): """ self.log(DEBUG, format_string, *args) - def info(self, format_string, *args): + def info(self, format_string: str, *args): """Log a info message. :param format_string: the core message string with embedded formatting directives @@ -182,7 +182,7 @@ def info(self, format_string, *args): """ self.log(INFO, format_string, *args) - def warning(self, format_string, *args): + def warning(self, format_string: str, *args): """Log a warning message. :param format_string: the core message string with embedded formatting directives @@ -191,7 +191,7 @@ def warning(self, format_string, *args): """ self.log(WARNING, format_string, *args) - def error(self, format_string, *args): + def error(self, format_string: str, *args): """Log a error message. :param format_string: the core message string with embedded formatting directives @@ -200,7 +200,7 @@ def error(self, format_string, *args): """ self.log(ERROR, format_string, *args) - def critical(self, format_string, *args): + def critical(self, format_string: str, *args): """Log a critical message. :param format_string: the core message string with embedded formatting directives @@ -217,30 +217,30 @@ class NullLogger: def __init__(self): """Dummy implementation.""" - def setLevel(self, value): + def setLevel(self, value: int): """Dummy implementation.""" - def getEffectiveLevel(self): + def getEffectiveLevel(self) -> int: """Dummy implementation.""" return NOTSET - def addHandler(self, hldr): + def addHandler(self, hldr: LoggingHandler): """Dummy implementation.""" - def log(self, level, format_string, *args): + def log(self, level: int, format_string: str, *args): """Dummy implementation.""" - def debug(self, format_string, *args): + def debug(self, format_string: str, *args): """Dummy implementation.""" - def info(self, format_string, *args): + def info(self, format_string: str, *args): """Dummy implementation.""" - def warning(self, format_string, *args): + def warning(self, format_string: str, *args): """Dummy implementation.""" - def error(self, format_string, *args): + def error(self, format_string: str, *args): """Dummy implementation.""" - def critical(self, format_string, *args): + def critical(self, format_string: str, *args): """Dummy implementation.""" From 2dc7ac66c629616cc2fd7554538c7da5ff005b88 Mon Sep 17 00:00:00 2001 From: tekktrik <89490472+tekktrik@users.noreply.github.com> Date: Mon, 25 Oct 2021 20:16:49 -0400 Subject: [PATCH 3/4] Fix typo for argument --- adafruit_logging.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_logging.py b/adafruit_logging.py index 1974861..289d6aa 100644 --- a/adafruit_logging.py +++ b/adafruit_logging.py @@ -62,7 +62,7 @@ def level_for(value: int) -> str: class LoggingHandler: """Abstract logging message handler.""" - def format(self, leve: int, msg: str) -> str: + def format(self, level: int, msg: str) -> str: """Generate a timestamped message. :param level: the logging level From 48782cb2d3caa18e3fdc46152194e21f7dadcbbf Mon Sep 17 00:00:00 2001 From: tekktrik <89490472+tekktrik@users.noreply.github.com> Date: Mon, 25 Oct 2021 21:40:52 -0400 Subject: [PATCH 4/4] Change CRLF to LF --- adafruit_logging.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_logging.py b/adafruit_logging.py index 289d6aa..2a8b330 100644 --- a/adafruit_logging.py +++ b/adafruit_logging.py @@ -98,7 +98,7 @@ def emit(self, level: int, msg: str): null_logger = None # pylint:disable=global-statement -def getLogger(name: str) -> 'Logger': +def getLogger(name: str) -> "Logger": """Create or retrieve a logger by name. :param name: the name of the logger to create/retrieve None will cause the