Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

logging.py: CPython-compatible logging improvements. #806

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Mar 21, 2024

  1. logging.py: CPython-compatible logging improvements.

    This commit allows for logging handlers to be added to the root logger
    and then used by non-root loggers that don't have their own handlers.
    
    It also adds the (CPython-compatible) handlers argument
    to logging.basicConfig() to ease this initialization:
    
        import logging
        sh = logging.StreamHandler()
        fh = logging.FileHandler("my.log", mode="a")
        logging.basicConfig(handlers=[sh, fh])
    
        root_logger = logging.getLogger() # uses sh and fh
        another_logger = logging.getLogger("another") # inherits handlers
    
    
    It also adds the Logger.removeHandler() method and avoids repeated handler
    addition.
    
    It also adds the flush() method to StreamHandler and its subclasses.
    
    It also correctly calls the superclass constructor from the StreamHandler
    constructor and uses a default formatter if a Handler has none
    set (as in PR micropython#710).
    
    Signed-off-by: Ned Konz <ned@productcreationstudio.com>
    ned-pcs committed Mar 21, 2024
    Configuration menu
    Copy the full SHA
    94a38ab View commit details
    Browse the repository at this point in the history