Can Python's logging format be modified depending on the message log level?
问题 I'm using Python's logging mechanism to print output to the screen. I could do this with print statements, but I want to allow a finer-tuned granularity for the user to disable certain types of output. I like the format printed for errors, but would prefer a simpler format when the output level is "info." For example: logger.error("Running cmd failed") logger.info("Running cmd passed") In this example, I would like the format of the error to be printed differently: # error Aug 27, 2009 -