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

Ensure proper log line/filename in warning/errors #3038

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

Commits on Oct 29, 2023

  1. Rework log (setup and filtering) implementation

    Overview
    ========
    Motivated by issue getpelican#3037 (Ensure proper log line/filename in
    warning/errors).
    
    ``pelican.log`` is no longer required to be early in the import order,
    as the package no longer relies on a custom logging class.
    
    Logging setup is now uncoupled so that format and filters can be applied
    independently, which makes both setup and testing more flexible.
    
    Behavior of commandline calls have not changed, except for some
    modification to help texts.
    
    ``LOG_FATAL`` and ``LOG_ONCE_LEVEL`` are new configuration keys.
    
    Summary of changes
    ==================
    
    :pelican/__init__.py:
    
        * Parsing commandline:
            * Unify type-converstion from string to logging levels.
            * Tweak some help text in ``parse_arguments``.
        * Preserve ``log`` namespace throughout (for clarity).
        * FIX: ``pelican.listen`` verbosity: avoid assumption that the
          logger's level will be NOTSET.
    
    :pelican/log.py:
    
        * FIX (getpelican#3037): warnings & errors now display the correct line numbers.
        * Split logging filters with focus on a specific aspect of behavior.
          This allows for more
            a) independence in testing and
            b) powerful logger configuration, with fewer side effects.
        * Isolate configuration *reading* from configuration *application*
          (see ``pelican/settings.py``).
    
    :pelican/settings.py:
    
        * Remove ``pelican.log`` dependency.
        * Isolate configuration *reading* from configuration *application*;
          to remove dependency on a global state when modifying log filters.
        * Add validation for LOG_LIMIT values.
    
    :pelican/tests/__init__.py:
    
        * Remove dependency on ``pelican.log`` module as test runners setup
          their own console handler anyway.
        * Only add ``NullHandler`` in absence of a configured logger.
    
    :pelican/tests/support.py:
    
        * Remove ``LoggedTestCase`` class; tests requiring logging analysis
          use a contextmanager (``LogCountHandler.examine``) instead.
    
    :pelican/tests/test_log.py:
    
        * Rewrite to reflect changes in pelican's logging module.
        * Increase code coverage.
    
    :pelican/tests/test_contents.py:
    :pelican/tests/test_pelican.py:
    :pelican/tests/test_utils.py:
    
        * Import ``unittest`` directly, rather than from other modules.
        * Switch to using contextmanager (``LogCountHandler.examine``) for
          test-specific log inspection.
        * Remove dependency on a custom TestCase (used in logging analysis).
        * Remove code involved with temporarily disabling log filters --
          the filters in question are now only enabled in tests directly
          testing them (eg. in ``test_log.py``)
    
    :pelican/tests/test_settings.py:
    
        * Add test for LOG_FILTER values from configs.
    copperchin committed Oct 29, 2023
    Configuration menu
    Copy the full SHA
    b662bdb View commit details
    Browse the repository at this point in the history