add timestamp to all log lines
authorThomasV <thomasv@gitorious>
Fri, 16 Nov 2012 13:49:03 +0000 (17:49 +0400)
committerThomasV <thomasv@gitorious>
Fri, 16 Nov 2012 13:49:03 +0000 (17:49 +0400)
backends/bitcoind/blockchain_processor.py
processor.py
server.py

index ae3d590..73fe481 100644 (file)
@@ -111,7 +111,7 @@ class BlockchainProcessor(Processor):
                 shared.stop()
                 sys.exit(0)
 
-        print "blockchain is up to date."
+        print_log( "blockchain is up to date." )
 
         threading.Timer(10, self.main_iteration).start()
 
@@ -449,7 +449,7 @@ class BlockchainProcessor(Processor):
         self.db.Write(batch, sync = sync)
 
         t3 = time.time()
-        if t3 - t0 > 10: 
+        if t3 - t0 > 10 and not sync: 
             print_log("block", block_height, 
                       "parse:%0.2f "%(t00 - t0), 
                       "read:%0.2f "%(t1 - t00), 
index c6972f8..5590874 100644 (file)
@@ -17,7 +17,7 @@ print_lock = threading.Lock()
 def print_log(*args):
     args = [str(item) for item in args]
     with print_lock:
-        sys.stderr.write(" ".join(args) + "\n")
+        sys.stderr.write(timestr() + " " + " ".join(args) + "\n")
         sys.stderr.flush()
 
 
@@ -234,7 +234,7 @@ class Session:
             addr = None
 
         if self.subscriptions:
-            print_log( timestr(), self.name, self.address, addr, len(self.subscriptions), self.version )
+            print_log( "%4s"%self.name, "%14s"%self.address, "%35s"%addr, "%3d"%len(self.subscriptions), self.version )
 
     def stopped(self):
         with self.lock:
index 6ada775..9ef014d 100755 (executable)
--- a/server.py
+++ b/server.py
@@ -114,7 +114,7 @@ if __name__ == '__main__':
         run_rpc_command(sys.argv[1], stratum_tcp_port)
         sys.exit(0)
 
-    from processor import Dispatcher
+    from processor import Dispatcher, print_log
     from backends.irc import ServerProcessor
 
     backend_name = config.get('server', 'backend')
@@ -128,7 +128,8 @@ if __name__ == '__main__':
         print "Unknown backend '%s' specified\n" % backend_name
         sys.exit(1)
 
-    print "\n\n\n\nStarting Electrum server on", host
+    for i in range(5): print ""
+    print_log( "Starting Electrum server on", host)
 
     # Create hub
     dispatcher = Dispatcher()
@@ -172,5 +173,5 @@ if __name__ == '__main__':
         except:
             shared.stop()
 
-    print "Electrum Server stopped"
+    print_log( "Electrum Server stopped")