New submission from Nan Hua <nanhua2...@gmail.com>:
As I see, Python's logging module's implementation has a nice property that, when no additional args are passed in, the msg (first argument) will be directly printed. For example, logging.error('abc %s') can be handled peacefully with printing "ERROR:root:abc %s" in the log. However, the logging's documentation only said the followings: "The msg is the message format string, and the args are the arguments which are merged into msg using the string formatting operator." >From what I see, this implementation (seems the case for both Python2 and >Python3) has many benefits: saving CPU resources, safe handling pre-formated >string, etc. More importantly, it also de-facto allows using the convenient >f-string in logging statement, e.g. logging.error(f'Started at {start_time}, finished at {finish_time}' f' by user {user}') can run correctly and smoothly even with user containing %s inside. In summary, I hope this de-facto actual behavior can be officially endorsed, with wordings like, "When *args is empty, i.e. no additional positional arguments passed in, the msg be of any string (no need to be a format string) and will be directly used as is without interpolation." What do you think? Thank you a lot! ---------- components: Library (Lib) messages: 364920 nosy: nhua priority: normal severity: normal status: open title: Document the behavior that no interplotation is applied when no *args are passed in for logging statements type: behavior versions: Python 3.9 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue40053> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com