Jun-27-2020, 03:57 AM
Hi,
I use the below code, and I want the messages to be left-aligned, meaning I want to align the columns.
I use the below code, and I want the messages to be left-aligned, meaning I want to align the columns.
import logging from datetime import datetime logging.basicConfig(level=logging.DEBUG, format='%(asctime)s.%(msecs)04d:%(levelname)s: %(message)s', filename=('mylog'+datetime.today().strftime('%Y%m%d_%H%M%S')+".txt"), filemode='w',datefmt='%Y-%m-%d %H:%M:%S') logging.debug('A debug message') logging.info('Info message') logging.warning('Warning message')current output:
2020-06-27 11:52:26.201:DEBUG: A debug message 2020-06-27 11:52:26.202:INFO: Info message 2020-06-27 11:52:26.202:WARNING: Warning messagedesired output:
2020-06-27 11:52:26.201:DEBUG: A debug message 2020-06-27 11:52:26.202:INFO: Info message 2020-06-27 11:52:26.202:WARNING: Warning message