@@ -2045,6 +2045,9 @@ def basicConfig(**kwargs):
20452045 created FileHandler, causing it to be used when the file is
20462046 opened in text mode. If not specified, the default value is
20472047 `backslashreplace`.
2048+ formatter_class
2049+ If specified, use the given class to instantiate the formatter.
2050+ If not specified, the default value is `logging.Formatter`.
20482051
20492052 Note that you could specify a stream created using open(filename, mode)
20502053 rather than passing the filename and mode in. However, it should be
@@ -2067,6 +2070,9 @@ def basicConfig(**kwargs):
20672070
20682071 .. versionchanged:: 3.9
20692072 Added the ``encoding`` and ``errors`` parameters.
2073+
2074+ .. versionchanged:: 3.14
2075+ Added the ``formatter_class`` parameter.
20702076 """
20712077 # Add thread safety in case someone mistakenly calls
20722078 # basicConfig() from multiple threads
@@ -2107,8 +2113,9 @@ def basicConfig(**kwargs):
21072113 if style not in _STYLES :
21082114 raise ValueError ('Style must be one of: %s' % ',' .join (
21092115 _STYLES .keys ()))
2116+ formatter_class = kwargs .pop ("formatter_class" , Formatter )
21102117 fs = kwargs .pop ("format" , _STYLES [style ][1 ])
2111- fmt = Formatter (fs , dfs , style )
2118+ fmt = formatter_class (fs , dfs , style )
21122119 for h in handlers :
21132120 if h .formatter is None :
21142121 h .setFormatter (fmt )
0 commit comments