CircuitPython version 7.3.1
adafruit_logging version 4.1.1
Running the example logging.simpletest from the library bundle with logger.setlevel set to NOTSET does not disable logging as documented.
Here is the code I ran.
Code: Select all
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT
# pylint:disable=undefined-variable,wildcard-import,no-name-in-module
# pylint:disable=no-member,invalid-name
"""Briefly exercise the logger and null logger."""
import adafruit_logging as logging
# This should produce an error output
logger = logging.getLogger("test")
print_logger = logging.StreamHandler()
logger.addHandler(print_logger)
logger.setLevel(logging.NOTSET)
logger.info("Info message\n")
logger.error("Error message\n")
# This should produce no output
null_logger = logging.getLogger("null")
null_handler = logging.NullHandler()
null_logger.addHandler(null_handler)
null_logger.setLevel(logging.ERROR)
null_logger.info("Info message")
null_logger.error("Error message")
The NullHandler section of code does work. Is this the recommended method to disable logging? Should the library documentation be updated?
Thanks in advance.
TonyC