KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm using python logging and I have a formatter that looks like the following: formatter = logging.Formatter( '%(asctime)s - %(pathname)86s - %(lineno)4s - %(message)s', '%d %H:%M' ) As you can see, I like the information in my log files to line up neatly in columns. The reason I have 86 spaces reserved for the pathname is because the full paths to some of the files used in my program are that long. However, all I really need is the actual file name, not the full path. How can I get the logging module to give me just the file name? Better yet, since I have some long filenames, I'd like the first 3 characters of the filename, followed by '~', then the last 16 characters. So /Users/Jon/important_dir/dev/my_project/latest/testing-tools/test_read_only_scenarios_happily.py should become tes~arios_happily.py
Tags (comma-separated)
Save Edits
Cancel