Reputation: 27129
At the moment we handle log message from our python scripts like this:
This works well, but if there are newlines in the log message, this does not work, since the check-logfiles tool works line based.
Example:
logger.info('foo\nbar')
Example output:
2014-07-10 11:52:11 foo.utils.importutils: INFO [18473] foo
bar
The foo
line gets filtered, but bar
gets mailed to us.
How to handle this better? I want foo\nbar
be handled like one message.
Upvotes: 1
Views: 344
Reputation: 44152
e.g. with logbook
package, logbook.MailHandler handler can handle even complex log records, there is even an option to set up template, rendering e-mail content based on logged record attributes.
The log record in this case holds log message in a structure, which does not suffer from new lines mess as if you write the logs to text file.
Python stdlib logging also provides SMTPHandler, but here I cannot serve with real experience.
Upvotes: 1