Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/sphinx-doc/sphinx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2020-03-21 13:26:52 +0300
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2020-03-21 13:26:52 +0300
commit0c45776c07583ca237a134f176d9be2e0aa7043f (patch)
tree7e509ae33572870d285bf0d43acc9e92ca121891 /sphinx/util/logging.py
parentc75470f9b79046f6d32344be5eacf60a4e1c1b7d (diff)
refactor SphinxLoggerAdapter
Diffstat (limited to 'sphinx/util/logging.py')
-rw-r--r--sphinx/util/logging.py14
1 files changed, 4 insertions, 10 deletions
diff --git a/sphinx/util/logging.py b/sphinx/util/logging.py
index a2dee807d..6827fd5cd 100644
--- a/sphinx/util/logging.py
+++ b/sphinx/util/logging.py
@@ -118,6 +118,7 @@ class SphinxWarningLogRecord(SphinxLogRecord):
class SphinxLoggerAdapter(logging.LoggerAdapter):
"""LoggerAdapter allowing ``type`` and ``subtype`` keywords."""
+ KEYWORDS = ['type', 'subtype', 'location', 'nonl', 'color']
def log(self, level: Union[int, str], msg: str, *args: Any, **kwargs: Any) -> None:
if isinstance(level, int):
@@ -131,16 +132,9 @@ class SphinxLoggerAdapter(logging.LoggerAdapter):
def process(self, msg: str, kwargs: Dict) -> Tuple[str, Dict]: # type: ignore
extra = kwargs.setdefault('extra', {})
- if 'type' in kwargs:
- extra['type'] = kwargs.pop('type')
- if 'subtype' in kwargs:
- extra['subtype'] = kwargs.pop('subtype')
- if 'location' in kwargs:
- extra['location'] = kwargs.pop('location')
- if 'nonl' in kwargs:
- extra['nonl'] = kwargs.pop('nonl')
- if 'color' in kwargs:
- extra['color'] = kwargs.pop('color')
+ for keyword in self.KEYWORDS:
+ if keyword in kwargs:
+ extra[keyword] = kwargs.pop(keyword)
return msg, kwargs