summaryrefslogtreecommitdiffstats
path: root/SCons/Util.py
diff options
context:
space:
mode:
Diffstat (limited to 'SCons/Util.py')
-rw-r--r--SCons/Util.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/SCons/Util.py b/SCons/Util.py
index 49a3a0f..476d4d6 100644
--- a/SCons/Util.py
+++ b/SCons/Util.py
@@ -35,6 +35,7 @@ from collections.abc import MappingView
from contextlib import suppress
from types import MethodType, FunctionType
from typing import Optional, Union
+from logging import Formatter
# Note: Util module cannot import other bits of SCons globally without getting
# into import loops. Both the below modules import SCons.Util early on.
@@ -2159,6 +2160,17 @@ def wait_for_process_to_die(pid):
else:
time.sleep(0.1)
+# From: https://stackoverflow.com/questions/1741972/how-to-use-different-formatters-with-the-same-logging-handler-in-python
+class DispatchingFormatter(Formatter):
+
+ def __init__(self, formatters, default_formatter):
+ self._formatters = formatters
+ self._default_formatter = default_formatter
+
+ def format(self, record):
+ formatter = self._formatters.get(record.name, self._default_formatter)
+ return formatter.format(record)
+
# Local Variables:
# tab-width:4
# indent-tabs-mode:nil