Python special cases single Mapping arguments to logging. This
adjusts BaseFormatter to skip "fancy" formatting if argument
is of type Mapping. Also adds various formatted log outputs.
This commit removes Six as a dependency for Pelican, replacing the
relevant aliases with the proper Python 3 imports. It also removes
references to Python 2 logic that did not require Six.
Fixes two bugs that was introduced by #1743:
- First was the unnecessary exception name output when skipping
content files if a required metadata wasn't available.
It was
`ERROR: Skipping ./demo.rst: could not find information about 'NameError: date'`
and now should be
`ERROR: Skipping ./demo.rst: could not find information about 'date'`
- Second was a more serious issue. Improper string formatting in the logger
resulted in implicit decoding and would break for non-ascii error messages.
When using nose to directly run the test suite it 'steals' stdout per
default. This causes the old implementation of ANSI detection to error
as stdout does not have a fileno function anymore.
The default configuration for the warnings module changed some time ago
so we lost the ability to detect deprecation warnings and such early.
This commit sets up the test suite to redirect all warnings through our
logging system. Additionally we enable DeprecationWarnings as a default
and throw exceptions on all warnings related to pelican modules.
This enables output of warnings related to dependencies, while letting
tests only fail if the warnings are originating from pelican's source.
Also adding a test to detect if warnings cause an Exception as expected.
To test the output of warning functions it can be useful to disable the
log filter, producing the expected output instead of the limited output
that is used during normal operation.
Adds exception type to the exception logging.
Removes the extra logging for autoreload in debug mode, since `raise`
will make it caught by the global `try/except` below and it'll be
logged there.
This replaces #1723 and also removes extra exception logging caused
in #1718.
Old system was using manual string formatting for log messages.
This caused issues with common operations like exception logging
because often they need to be handled differently for Py2/Py3
compatibility. In order to unify the effort:
- All logging is changed to `logging.level(msg, arg1, arg2)` style.
- A `SafeLogger` is implemented to auto-decode exceptions properly
in the args (ref #1403).
- Custom formatters were overriding useful logging functionality
like traceback outputing (ref #1402). They are refactored to be
more transparent. Traceback information is provided in `--debug`
mode for `read_file` errors in generators.
- Formatters will now auto-format multiline log messages in order
to make them look related. Similarly, traceback will be formatted in
the same fashion.
- `pelican.log.LimitFilter` was (ab)using logging message which
would result in awkward syntax for argumented logging style. This
functionality is moved to `extra` keyword argument.
- Levels for errors that would result skipping a file (`read_file`)
changed from `warning` to `error` in order to make them stand out
among other logs.
- Small consistency changes to log messages (i.e. changing all
to start with an uppercase letter) and quality-of-life improvements
(some log messages were dumping raw object information).
Drop duplicates logs.
Allow for logs to be grouped, enforcing a maximum number of logs per group.
Add the LOG_FILTER setting to ask from the configuration file to ignore some
logs (of level up to warning).