python logging string formatting

Viewed 24275

I am using python's log formatter to format log records and i have a fmt value of

fmt = "[%(filename)s:%(lineno)s] %(message)s"

What i would like is that "[file.py:20]" to be stretched to 10 characters wide (for example). If it was one value that would have been easy but is there any way to stretch this entire structure to a specified length? I want something like:

tmp = "[%(filename)s:%(lineno)s]"
fmt = "%(tmp)10s %(message)s"

I would like to know if this is possible using string formatting or if I can trick python's formatter somehow to get what i want..

3 Answers
Related