zephyr_mirror: Don't open /dev/null to disable logging

(imported from commit 804e627d6d70bbf2ae1ee2f467b79ed0582ced0f)
This commit is contained in:
Keegan McAllister 2012-11-01 17:38:31 -04:00
parent 6329bb0a46
commit 3db339da35

View file

@ -272,6 +272,7 @@ def process_notice(notice, log):
print "%s: zephyr=>humbug: received a message on %s/%s from %s..." % \ print "%s: zephyr=>humbug: received a message on %s/%s from %s..." % \
(datetime.datetime.now(), zephyr_class, notice.instance, notice.sender) (datetime.datetime.now(), zephyr_class, notice.instance, notice.sender)
if log is not None:
log.write(simplejson.dumps(zeph) + '\n') log.write(simplejson.dumps(zeph) + '\n')
log.flush() log.flush()
@ -342,12 +343,10 @@ def zephyr_to_humbug(options):
print "%s: zephyr=>humbug: Starting receive loop." % (datetime.datetime.now(),) print "%s: zephyr=>humbug: Starting receive loop." % (datetime.datetime.now(),)
if options.log_path is not None: if options.log_path is not None:
log_file = options.log_path with open(options.log_path, 'a') as log:
else:
log_file = "/dev/null"
with open(log_file, 'a') as log:
process_loop(log) process_loop(log)
else:
process_loop(None)
def forward_to_zephyr(message): def forward_to_zephyr(message):
zsig = u"%s@(@color(blue))" % (username_to_fullname(message["sender_email"]),) zsig = u"%s@(@color(blue))" % (username_to_fullname(message["sender_email"]),)