-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
Description
Bug report
Creating a new formatter in a dictConfig requires the format string to be specified with the key "format" instead of "fmt".
This is inconsistent with the syntax for the class constructor.
Furthermore, the result is that the resulting formatter quietly drops the specified format string replacing it with {message} for no apparent reason.
While the documentation states "format" as key name, all other keys are identically named to the constructor and this causes an unnecessary risk for confusion and errors. Especially since "fmt" and "format" do read very similarly.
I believe it would be a good addition to allow the key "fmt" to be read equivalently to "format" since this may be unwanted behaviour.
MWE:
import logging
config = {
"version": 1,
"formatters": {
"default": { "fmt": "%(levelname)s %(message)s" }
},
"handlers": {
"console": {
"class": "logging.StreamHandler",
"formatter": "default"
}
},
"loggers": {
"log": { "handlers": ["console"] }
}
}
logging.config.dictConfig(config)
logging.info("test")Causes the log record to drop the levelname.
Your environment
Python 3.11.2 (tags/v3.11.2:878ead1, Feb 7 2023, 16:38:35) [MSC v.1934 64 bit (AMD64)] on win32
Windows 11 64 bit
P.S.: This is my first bug report in a project of such size, please kindly help me improving if needed.
EDIT: added link to documentation of Dictionary Schema Details.
Linked PRs
Metadata
Metadata
Assignees
Labels
Projects
Status

