Do not write to logfile if None
authorLaurent Bachelier <laurent@bachelier.name>
Tue, 16 Apr 2013 21:22:47 +0000 (23:22 +0200)
committerEric S. Raymond <esr@thyrsus.com>
Tue, 16 Apr 2013 21:35:58 +0000 (17:35 -0400)
Signed-off-by: Eric S. Raymond <esr@thyrsus.com>
irkerd

diff --git a/irkerd b/irkerd
index 7a6256e84b5fd69583b2891cd8cce07adc516306..ca0d61704b77c347266f49cbfe2e324dd8fe0803 100755 (executable)
--- a/irkerd
+++ b/irkerd
@@ -479,8 +479,9 @@ class Irker:
             connection.context.handle_kick(target)
     def _handle_all_raw_messages(self, _connection, event):
         "Log all messages when in watcher mode."
-        with open(logfile, "a") as logfp:
-            logfp.write("%03f|%s|%s\n" % \
+        if logfile:
+            with open(logfile, "a") as logfp:
+                logfp.write("%03f|%s|%s\n" % \
                              (time.time(), event.source, event.arguments[0]))
     def handle(self, line):
         "Perform a JSON relay request."