I am using pythons logging module, and I would like to have a simple change to my logging message. Here is what the formatter looks like, and the result:
console_err_format = logging.Formatter(
str("%(asctime)s - " + "%(levelname)s" +" - %(message)s"),
"%H:%M:%S")
12:35:33 - INFO - Assessing reads and library type
12:35:33 - DEBUG - Checking reads...
12:35:33 - WARNING - Error while checking reads...
I would like just the first character of the logger level to be shown:
12:35:33 - I - Assessing reads and library type
12:35:33 - D - Checking reads...
12:35:33 - W - Error while checking reads...
Does anyone know how to do this? I have tried the following things, to no avail:
# attempt 1
console_err_format = logging.Formatter(
str("%(asctime)s - " +"{0}".format("%(levelname)s"[:1]) +" - %(message)s"), "%H:%M:%S")
# attempt 2
console_err_format = logging.Formatter(
str("%(asctime)s - " +"%(levelname)s"[:1] +" - %(message)s"), "%H:%M:%S")
Any tips would be appreciated! Bonus points if anyone has figured out howto integrate one of the color logging modules!