import logging
import boto.sns
class SNSHandler(logging.Handler):
def __init__(self, topic_arn, *args, **kwargs):
super(SnsHandler, self).__init__(*args, **kwargs)
region_name = topic_arn.split(':')[3]
self.sns_connection = boto.sns.connect_to_region(region_name)
self.topic_arn = topic_arn
def emit(self, record):
subject = u'{}:{}'.format(record.name, record.levelname)
self.sns_connection.publish(
self.topic_arn,
self.format(record),
subject=subject.encode('ascii', errors='ignore')[:99])
Diff to Previous Revision
--- revision 1 2014-11-06 17:29:23
+++ revision 2 2014-11-06 17:32:26
@@ -12,8 +12,7 @@
self.topic_arn = topic_arn
def emit(self, record):
- subject = u'[ca.activity] {}:{}'.format(record.name,
- record.levelname)
+ subject = u'{}:{}'.format(record.name, record.levelname)
self.sns_connection.publish(
self.topic_arn,
self.format(record),