[New-bugs-announce] [issue31080] Allow `logging.config.fileConfig` to accept kwargs

Preston Landers report at bugs.python.org
Sun Jul 30 13:10:10 EDT 2017


New submission from Preston Landers:

The function `logging.config.fileConfig` accepts `args` but it would be nice if it also accepted `kwargs`.

A simple patch seems to do it:

	diff --git a/Lib/logging/config.py b/Lib/logging/config.py
	index d692514..4672b48 100644
	--- a/Lib/logging/config.py
	+++ b/Lib/logging/config.py
	@@ -145,7 +145,9 @@ def _install_handlers(cp, formatters):
				 klass = _resolve(klass)
			 args = section["args"]
			 args = eval(args, vars(logging))
	-        h = klass(*args)
	+        kwargs = section.get("kwargs", '{}')
	+        kwargs = eval(kwargs, vars(logging))
	+        h = klass(*args, **kwargs)
			 if "level" in section:
				 level = section["level"]
				 h.setLevel(level)


Unless there are any objections I plan to submit a pull request. In my use case I have a Pyramid service which
uses `concurrent-log-handler` and it seems better to be able to name keyword args for file configuration.

----------
components: Library (Lib)
messages: 299502
nosy: planders
priority: normal
severity: normal
status: open
title: Allow `logging.config.fileConfig` to accept kwargs
type: enhancement

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue31080>
_______________________________________


More information about the New-bugs-announce mailing list