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

Cleanup Logging Configuration #4435

Merged
merged 7 commits into from
Sep 21, 2023

Commits on Sep 20, 2023

  1. Remove unnecessary logging wrapper in Cloud class (canonical#4435)

    Cloud.cycle_logging() is only called once in the codebase, and its only
    benefit is turning two function calls into a single call. Remove it.
    holmanb committed Sep 20, 2023
    Configuration menu
    Copy the full SHA
    3434db7 View commit details
    Browse the repository at this point in the history
  2. cloudinit.log: Standardize use of cloudinit's logging module (canonic…

    …al#4435)
    
    cloud-init's log module implements a wrapper for logging.getLogger,
    however this module is not consistently used across the codebase. Furthermore
    most of these invocations choose to alias cloudinit.log module to logging.
    Shadowing a standard library module, and especially doing so inconsistently
    across the codebase, is not best practice. Since this wrapper doesn't add
    value, replace all invocations with the standard library call.
    
    Also standardize logger names to use logging.getLogger(__name__).
    holmanb committed Sep 20, 2023
    Configuration menu
    Copy the full SHA
    b561666 View commit details
    Browse the repository at this point in the history
  3. cloudinit.log: Remove unused getLogger wrapper (canonical#4435)

    This wrapper provided a default logger with name "cloudinit" when called
    without arguments. This behavior was never used and can safely be removed.
    holmanb committed Sep 20, 2023
    Configuration menu
    Copy the full SHA
    0ce9acf View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    f9d7b61 View commit details
    Browse the repository at this point in the history
  5. Simplify root logger configuration (canonical#4435)

    The root logger gets configured at various stages of cloudinit execution.
    Some changes occur while importing cloudinit.log, which causes side effects
    in any project using cloudinit as a library (Ubuntu Pro, etc). These
    modifications do not require change during runtime and can take place as
    an early setup task in cloudinit.cmd.main::main().
    
    Simplify this code, relocate logger configuration code to a function in
    cloudinit.log, set the callsite in cloudinit.cmd.main::main().
    
    Also add context to logging configuration code.
    holmanb committed Sep 20, 2023
    Configuration menu
    Copy the full SHA
    cf812f6 View commit details
    Browse the repository at this point in the history
  6. cloudinit.log: Don't configure NullHandler (canonical#4435)

    NullHandler hasn't been required to prevent the logging warnings since
    commit 5a27d4018 landed in Python, which was released in Python 3.2.
    holmanb committed Sep 20, 2023
    Configuration menu
    Copy the full SHA
    0d99945 View commit details
    Browse the repository at this point in the history
  7. cloudinit.log: Use more appropriate exception (canonical#4435)

    cloud-init's logging code has for a long time caught and ignored a bare
    Exception. Use a more specific exception for the expected case that this
    handles.
    holmanb committed Sep 20, 2023
    Configuration menu
    Copy the full SHA
    b13037c View commit details
    Browse the repository at this point in the history