provide "extractor" and "job" keys for logging output

This allows for stuff like "{extractor.url}" and "{extractor.category}"
in logging format strings.
Accessing 'extractor' and 'job' in any way will return "None" if those
fields aren't defined, i.e. in general logging messages.
This commit is contained in:
Mike Fährmann
2019-02-13 17:39:43 +01:00
parent 32edf4fc7b
commit ae353ed3b0
5 changed files with 160 additions and 94 deletions

View File

@@ -1432,7 +1432,14 @@ Description Extended logging output configuration.
* format
* Format string for logging messages
(see `LogRecord attributes <https://docs.python.org/3/library/logging.html#logrecord-attributes>`__)
In addition to the default
`LogRecord attributes <https://docs.python.org/3/library/logging.html#logrecord-attributes>`__,
it is also possible to access the current
`extractor <https://github.com/mikf/gallery-dl/blob/2e516a1e3e09cb8a9e36a8f6f7e41ce8d4402f5a/gallery_dl/extractor/common.py#L24>`__
and `job <https://github.com/mikf/gallery-dl/blob/2e516a1e3e09cb8a9e36a8f6f7e41ce8d4402f5a/gallery_dl/job.py#L19>`__
objects as well as their attributes
(e.g. ``"{extractor.url}"``)
* Default: ``"[{name}][{levelname}] {message}"``
* format-date
* Format string for ``{asctime}`` fields in logging messages