Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Abente <martin.abente.lahaye@gmail.com>2011-03-25 17:56:23 (GMT)
committer Martin Abente <martin.abente.lahaye@gmail.com>2011-03-25 17:56:23 (GMT)
commitae9ddd306161a995b213d31003971fa20a15791c (patch)
tree1dcd5dbe743d67145ea5e1dc63abc2b16e219e2a
parent9285efc6dd5c94524eb35533511f588ffdecff17 (diff)
Add custom log to mailer
-rw-r--r--config.ini.example1
-rwxr-xr-xreports_mailer.py15
-rw-r--r--sugar-fbserver.spec5
3 files changed, 15 insertions, 6 deletions
diff --git a/config.ini.example b/config.ini.example
index eaf929d..a6214fc 100644
--- a/config.ini.example
+++ b/config.ini.example
@@ -18,3 +18,4 @@ smtp_user: feedbackreporter
smtp_password: 123456
smtp_server: smtp.activitycentral.com
smtp_port: 25
+log_path: /home/tch/Devel/feedback-server/mailer.log
diff --git a/reports_mailer.py b/reports_mailer.py
index ac042c8..8b61840 100755
--- a/reports_mailer.py
+++ b/reports_mailer.py
@@ -20,6 +20,7 @@ import sys
import json
import time
import smtplib
+import logging
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from ConfigParser import ConfigParser
@@ -145,11 +146,11 @@ def check_reports():
try:
report_info = json.loads(report_data)
except Exception, e:
- print 'Error while parsing %s: %s' % (report_info_path, str(e))
+ logging.info('Error while parsing %s: %s' % (report_info_path, str(e)))
continue
if len(report_info.keys()) <= 0:
- print 'Empty report %s.' % report_info_path
+ logging.info('Empty report %s.' % report_info_path)
continue
body = generate_body(report_info, report_info_path)
@@ -159,21 +160,25 @@ def check_reports():
try:
send_email(message)
except Exception, e:
- print 'Error while sending %s: %s' % (report_info_path, str(e))
+ logging.info('Error while sending %s: %s' % (report_info_path, str(e)))
continue
emailed_mark_file = open(emailed_mark_path, 'w')
emailed_mark_file.close()
- print 'Marked %s.' % emailed_mark_path
+ logging.info('Marked %s.' % emailed_mark_path)
def load_configuration(config):
global REPORTS_PATH, REPORTER_ADDRESS, LIST_ADDRESS, \
SMTP_USER, SMTP_PASSWORD, SMTP_SERVER, SMTP_PORT
+ format = "%(asctime)s %(message)s"
+ log_path = config.get('mailer', 'log_path')
+ logging.basicConfig(filename=log_path, level=logging.INFO, format=format)
+
REPORTS_PATH = config.get('feedback', 'reports_path')
if not os.path.exists(REPORTS_PATH):
- print 'Reports directory (%s) does not exists.' % REPORTS_PATH
+ logging.error('Reports directory (%s) does not exists.' % REPORTS_PATH)
sys.exit(-1)
REPORTER_ADDRESS = config.get('mailer', 'reporter_address')
diff --git a/sugar-fbserver.spec b/sugar-fbserver.spec
index 8af033f..0908da4 100644
--- a/sugar-fbserver.spec
+++ b/sugar-fbserver.spec
@@ -1,6 +1,6 @@
Name: sugar-fbserver
Version: 0.2
-Release: 4
+Release: 5
Vendor: Activity Central
Summary: Sugar debugging feedback server
Group: Applications/Internet
@@ -59,6 +59,9 @@ chkconfig --level 345 fbserverd off
%changelog
+* Fri Mar 25 2011 Martin Abente. <martin.abente.lahaye@gmail.com>
+- Add custom log to mailer.
+
* Thu Mar 24 2011 Martin Abente. <martin.abente.lahaye@gmail.com>
- Improved email body content format
- Check mailer section existance.