-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework log (setup and filtering) implementation
Overview ======== Motivated by issue #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 (#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.
- Loading branch information
1 parent
84795c7
commit 14483fb
Showing
10 changed files
with
1,003 additions
and
367 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.