sawmill.formatter.email

sawmill.formatter.email.DEFAULT_TEMPLATE = "\n<html>\n <body>\n <h1>Logs</h1>\n {{#logs}}\n <span class='{{level}}'>\n {{timestamp}}:{{name}}:{{message}}{{#traceback}}<br/>{{.}}{{/traceback}}\n </span><br/>\n {{/logs}}\n </body>\n</html>\n"

Default html email template.

class sawmill.formatter.email.Email(subject, sender, recipients, template="n<html>n <body>n <h1>Logs</h1>n {{#logs}}n <span class='{{level}}'>n {{timestamp}}:{{name}}:{{message}}{{#traceback}}<br/>{{.}}{{/traceback}}n </span><br/>n {{/logs}}n </body>n</html>n", batch=True, **kw)[source]

Bases: sawmill.formatter.mustache.Mustache

Format logs to email messages.

__init__(subject, sender, recipients, template="\n<html>\n <body>\n <h1>Logs</h1>\n {{#logs}}\n <span class='{{level}}'>\n {{timestamp}}:{{name}}:{{message}}{{#traceback}}<br/>{{.}}{{/traceback}}\n </span><br/>\n {{/logs}}\n </body>\n</html>\n", batch=True, **kw)[source]

Initialise handler with subject, sender and recipients.

Each of subject, sender and recipients can be either a static string or a callable which will be passed the log records being handled and should return an appropriate value.

recipients should be (or return) a string of comma separated email addresses.

format(logs)[source]

Return email messages representing logs.

Each message will be an instance of Message. It will be setup as a multipart message containing both html and plain text versions of the logs formatted according to the set template.