Skip to content

Commit

Permalink
Add LogMessage action, which allows you to log messages that match a …
Browse files Browse the repository at this point in the history
…filter.
  • Loading branch information
Thomi Richards committed Jun 22, 2015
1 parent eb668e9 commit f599b34
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions gmailfilter/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,20 @@ class DeleteMessage(Action):
def process(self, conn, message):
conn.delete_messages(message.uid())
logging.info("Deleting message %r" % message)


class LogMessage(Action):

"""A Simple action that just logs the message."""

def __init__(self, message_template="LOG Message={}"):
"""Create a new LogMessage object.
The message_template string must be a string with a single '{}' in it,
which will be replaced with the message's repr().
"""
self.message_template = message_template

def process(self, conn, message):
logging.info(self.message_template.format(repr(message)))

0 comments on commit f599b34

Please sign in to comment.