Skip to content

Commit 65a3d8a

Browse files
committed
Add module-level .log functions.
1 parent 3799989 commit 65a3d8a

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

adafruit_logging.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,3 +617,51 @@ def exception(self, err: Exception) -> None:
617617
# so we can't add the indent in the above line - needs to be done separately
618618
lines = lines.replace("\n", "\n ")
619619
self._log(ERROR, lines)
620+
621+
def critical(msg, *args, **kwargs):
622+
"""
623+
Log a message with severity 'CRITICAL' on the root logger.
624+
"""
625+
getLogger().critical(msg, *args, **kwargs)
626+
627+
def fatal(msg, *args, **kwargs):
628+
"""
629+
Don't use this function, use critical() instead.
630+
"""
631+
critical(msg, *args, **kwargs)
632+
633+
def error(msg, *args, **kwargs):
634+
"""
635+
Log a message with severity 'ERROR' on the root logger.
636+
"""
637+
getLogger().error(msg, *args, **kwargs)
638+
639+
def warning(msg, *args, **kwargs):
640+
"""
641+
Log a message with severity 'WARNING' on the root logger.
642+
"""
643+
getLogger().warning(msg, *args, **kwargs)
644+
645+
def warn(msg, *args, **kwargs):
646+
"""
647+
Don't use this function, use warning() instead.
648+
"""
649+
warning(msg, *args, **kwargs)
650+
651+
def info(msg, *args, **kwargs):
652+
"""
653+
Log a message with severity 'INFO' on the root logger.
654+
"""
655+
getLogger().info(msg, *args, **kwargs)
656+
657+
def debug(msg, *args, **kwargs):
658+
"""
659+
Log a message with severity 'DEBUG' on the root logger.
660+
"""
661+
getLogger().debug(msg, *args, **kwargs)
662+
663+
def log(level, msg, *args, **kwargs):
664+
"""
665+
Log 'msg % args' with the integer severity 'level' on the root logger.
666+
"""
667+
getLogger().log(level, msg, *args, **kwargs)

0 commit comments

Comments
 (0)