Ticket 589: Baltrad-db log does not contain timestamps jenkins-baltrad-db-396
authorMats Vernersson <mats.vernersson@smhi.se>
Thu, 28 Apr 2016 09:11:28 +0000 (11:11 +0200)
committerMats Vernersson <mats.vernersson@smhi.se>
Thu, 28 Apr 2016 09:11:28 +0000 (11:11 +0200)
Logger has been updated so that timestamps are now included in log-outputs from baltrad-db.

server/src/baltrad/bdbserver/main.py

index 6cac7ac..6958ec9 100644 (file)
@@ -96,9 +96,13 @@ def configure_logging(opts, level=logging.INFO):
     logger.setLevel(level)
 
     if opts.foreground:
-        logger.addHandler(logging.StreamHandler(sys.stdout))
+        handler = logging.StreamHandler(sys.stdout)
     if opts.logfile:
-        logger.addHandler(logging.FileHandler(opts.logfile))
+        handler = logging.FileHandler(opts.logfile)
+    
+    formatter = logging.Formatter('%(asctime)-15s %(levelname)-8s %(message)s')
+    handler.setFormatter(formatter)
+    logger.addHandler(handler)
 
 ## Checks if the process with provided pid is running
 # by checking the /proc directory.