]> jfr.im git - erebus.git/commitdiff
log to file instead of stdout; logfile rotation
authorzonidjan <redacted>
Tue, 13 Sep 2016 13:24:52 +0000 (08:24 -0500)
committerzonidjan <redacted>
Tue, 13 Sep 2016 13:24:52 +0000 (08:24 -0500)
bot.py
erebus.py

diff --git a/bot.py b/bot.py
index 697638f7e8851e7db9fa9085d55592651a7b748f..c753fe17860649e248d578bcab6f6a6a754aaefa 100644 (file)
--- a/bot.py
+++ b/bot.py
@@ -236,6 +236,7 @@ class BotConnection(object):
        #TODO: rewrite send() to queue
        def send(self, line):
                print "%05.3f %s [O] %s" % (time.time() % 100000, self.parent.nick, line)
+               sys.stdout.flush()
 #              print (time.time() % 1466400000), self.parent.nick, '[O]', str(line)
                self._write(line)
 
@@ -249,6 +250,7 @@ class BotConnection(object):
                while "\r\n" in self.buffer:
                        pieces = self.buffer.split("\r\n", 1)
                        print "%05.3f %s [I] %s" % (time.time() % 100000, self.parent.nick, pieces[0])
+                       sys.stdout.flush()
 #                      print (time.time() % 1460000000), self.parent.nick, '[I]', pieces[0]
                        lines.append(pieces[0])
                        self.buffer = pieces[1]
index 1c62a4423e33adfc070751ddca6c338e64163977..e6c0459af897a6af79ec6cb085a1c01a8ecd22d0 100644 (file)
--- a/erebus.py
+++ b/erebus.py
@@ -284,5 +284,9 @@ def loop():
                        main.fd(fileno).parse(line)
 
 if __name__ == '__main__':
+       try: os.rename('logfile', 'oldlogs/%s' % (time.time()))
+       except: pass
+       sys.stdout = open('logfile', 'w')
+       sys.stderr = sys.stdout
        setup()
        while True: loop()