Skip to content

Commit e4fac46

Browse files
authored
Merge pull request #67 from fovea1959/module_level_calls
Add module-level .log functions.
2 parents 24c00a7 + 539f85d commit e4fac46

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

adafruit_logging.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,3 +617,59 @@ 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+
622+
def critical(msg, *args, **kwargs):
623+
"""
624+
Log a message with severity 'CRITICAL' on the root logger.
625+
"""
626+
getLogger().critical(msg, *args, **kwargs)
627+
628+
629+
def fatal(msg, *args, **kwargs):
630+
"""
631+
Don't use this function, use critical() instead.
632+
"""
633+
critical(msg, *args, **kwargs)
634+
635+
636+
def error(msg, *args, **kwargs):
637+
"""
638+
Log a message with severity 'ERROR' on the root logger.
639+
"""
640+
getLogger().error(msg, *args, **kwargs)
641+
642+
643+
def warning(msg, *args, **kwargs):
644+
"""
645+
Log a message with severity 'WARNING' on the root logger.
646+
"""
647+
getLogger().warning(msg, *args, **kwargs)
648+
649+
650+
def warn(msg, *args, **kwargs):
651+
"""
652+
Don't use this function, use warning() instead.
653+
"""
654+
warning(msg, *args, **kwargs)
655+
656+
657+
def info(msg, *args, **kwargs):
658+
"""
659+
Log a message with severity 'INFO' on the root logger.
660+
"""
661+
getLogger().info(msg, *args, **kwargs)
662+
663+
664+
def debug(msg, *args, **kwargs):
665+
"""
666+
Log a message with severity 'DEBUG' on the root logger.
667+
"""
668+
getLogger().debug(msg, *args, **kwargs)
669+
670+
671+
def log(level, msg, *args, **kwargs):
672+
"""
673+
Log 'msg % args' with the integer severity 'level' on the root logger.
674+
"""
675+
getLogger().log(level, msg, *args, **kwargs)

0 commit comments

Comments
 (0)