Antoine Pitrou <solipsis <at> pitrou.net> writes: > Why not allow logging.Formatter to take a callable, which would in turn call > the callable with keyword arguments? > > Therefore, you could write: > logging.Formatter("{asctime} - {name} - {level} - {msg}".format) > > and then: > logging.critical(name="Python", msg="Buildbots are down") This seems perhaps usable for a Formatter instantiation (infrequent) but a problem for the case where you want to convert format_str + args -> message (potentially frequent, and less readable). Another problem is that logging calls already use keyword arguments (extra, exc_info) and so backward compatibility might be compromised. It also feels like passing a callable could encourage patterns of usage which restrict our flexibility for future changes: we want for now to just allow choosing between % and {}, but a callable can do anything. That's more flexible, to be sure, but more specialized formatting requirements are already catered for using e.g. the PercentMessage/BraceMessage approach. Regards, Vinay Sajip
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4