Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pyDKB/logging: fix issue with multiline log message with arguments...
...and simplify logic of multiline formatting. Previously multiline message with arguments would fail with error: ``` >>> pyDKB.logger.error("%(line1)s\n%(line2)s", {"line1": "First line", ... "line2": "Second line"}) Traceback (most recent call last): File "/usr/lib/python2.6/site-packages/logging/__init__.py", line 723, in emit msg = self.format(record) File "/usr/lib/python2.6/site-packages/logging/__init__.py", line 609, in format return fmt.format(record) File "/home/mgolosova/dkb/Utils/Dataflow/pyDKB/common/_logging.py", line 162, in format result = (msg + extra + '\n'.join(lines[1:])) % record.__dict__ KeyError: 'line2' ``` Now the whole message goes to the `logger.Formatter.format()` function, thus message with argumets works perfectly fine. Then we format the suffix (as it is definitely the same for every line), and then `formatExtra()` just adds prefixes for extra lines and suffixes to all lines. It also saves from specific `formatException()` method, called from `logger.Formatter.format()`, as we do not need to think about prefixes and suffixes before the message is fully formatted and appended with traceback info. It also affects alignment: now suffix is aligned for all lines, not only traceback ones.
- Loading branch information