Add localtime to log file
authorClifford Wolf <clifford@clifford.at>
Sun, 11 Mar 2018 00:06:09 +0000 (01:06 +0100)
committerClifford Wolf <clifford@clifford.at>
Sun, 11 Mar 2018 00:06:09 +0000 (01:06 +0100)
Signed-off-by: Clifford Wolf <clifford@clifford.at>
sbysrc/sby_core.py

index 8a45f451ec83978c6d3952dfd2c470c6f5ae9711..59efebfe87362348301c8c94ab7691b74ca299a2 100644 (file)
@@ -20,7 +20,7 @@ import os, re, resource, sys
 import subprocess, fcntl
 from shutil import copyfile
 from select import select
-from time import time
+from time import time, localtime
 
 class SbyTask:
     def __init__(self, job, info, deps, cmdline, logfile=None, logstderr=True):
@@ -156,7 +156,6 @@ class SbyJob:
         ru = resource.getrusage(resource.RUSAGE_CHILDREN)
         self.start_process_time = ru.ru_utime + ru.ru_stime
 
-        self.logprefix = "SBY [%s]" % self.workdir
         self.summary = list()
 
         self.logfile = open("%s/logfile.txt" % workdir, "w")
@@ -279,8 +278,9 @@ class SbyJob:
                     self.terminate(timeout=True)
 
     def log(self, logmessage):
-        print("%s %s" % (self.logprefix, logmessage))
-        print("%s %s" % (self.logprefix, logmessage), file=self.logfile)
+        tm = localtime()
+        print("SBY %2d:%02d:%02d [%s] %s" % (tm.tm_hour, tm.tm_min, tm.tm_sec, self.workdir, logmessage))
+        print("SBY %2d:%02d:%02d [%s] %s" % (tm.tm_hour, tm.tm_min, tm.tm_sec, self.workdir, logmessage), file=self.logfile)
         self.logfile.flush()
 
     def copy_src(self):