Changes to log messages to support unicode

Change-Id: Iefb3b4d577d8c4dc4d2b1ace5c155d2dc3d5ef9c
This commit is contained in:
Ryan Brandt 2015-05-05 13:19:12 -06:00
parent f174a949da
commit ef0d82fbbc
3 changed files with 8 additions and 12 deletions

View File

@ -37,7 +37,8 @@ class AlarmProcessor(BaseProcessor):
try:
self._mysql = MySQLdb.connect(host=mysql_host, user=mysql_user,
passwd=unicode(mysql_passwd).encode('utf-8'),
db=dbname, ssl=mysql_ssl)
db=dbname, ssl=mysql_ssl,
use_unicode=True, charset="utf8")
self._mysql.autocommit(True)
except:
log.exception('MySQL connect failed')

View File

@ -84,15 +84,15 @@ class RetryEngine(object):
notification.retry_count += 1
notification.notification_timestamp = time.time()
if notification.retry_count < self._retry_max:
log.error("retry failed for {} with name {} "
"at {}. "
"Saving for later retry.".format(ntype, name, addr))
log.error(u"retry failed for {} with name {} "
u"at {}. "
u"Saving for later retry.".format(ntype, name, addr))
self._producer.publish(self._topics['retry_topic'],
[notification])
else:
log.error("retry failed for {} with name {} "
"at {} after {} retries. "
"Giving up on retry."
log.error(u"retry failed for {} with name {} "
u"at {} after {} retries. "
u"Giving up on retry."
.format(ntype, name, addr, self._retry_max))
self._consumer.commit([partition])

View File

@ -40,11 +40,6 @@ class WebhookNotifier(AbstractNotifier):
Posts on the given url
"""
self._log.info("Notifying alarm {} to {} with action {}"
.format(notification.alarm_name,
notification.state,
notification.address))
body = {'alarm_id': notification.alarm_id,
'alarm_definition_id': notification.raw_alarm['alarmDefinitionId'],
'alarm_name': notification.alarm_name,