feat: change logging format - #358
Conversation
| # create a new formatter with our desired format | ||
| formatter = Formatter( | ||
| '[{%(asctime)s} %(levelname)-7s %(filename)10s : %(lineno)-4s] %(funcName)30s %(message)s %(threadName)s', | ||
| '%(asctime)s %(levelname)s %(threadName)s %(name)s %(filename)s:%(lineno)s %(message)s', |
There was a problem hiding this comment.
Finding a particular log message within our codebase isn't difficult via search so I think %(filename)s:%(lineno)s should be removed too.
I'm keeping it for now to minimise this change but my recommendation is to remove it and start using the name field to properly identify logical units within our own code e.g. cwac.crawler, cwac.browser. This would be a single line change to the top of each module e.g. in crawler.py:
- logger = logging.getLogger('cwac')
+ logger = logging.getLogger('cwac.crawler')
G-Rath
left a comment
There was a problem hiding this comment.
I think we're going to need to discuss this more - personally I do find the aligning some of the columns with padding makes it easier to glance over the lines, and the function names have been useful to have since they're what I have in my mental model not individual line numbers.
When it comes to logs, I'm usually of the opinion that you should log more not less, because filtering and parsing is usually very cheap whereas its often very hard to extract information after the fact.
I'm fine with the rest of your changes though, if you want to get them landed
Improve log output. Changes are:
namefield. Lets us distinguish between logs emitted from our code (name=cwac) and libraries e.g. all ultimate-sitemap-parser logs arename=usp.*funcName. The log entries containfilenameandlineno. This is enough to find the line.funcNamejust adds noise.Example log output after this change