3
0
Fork 0
mirror of https://github.com/YosysHQ/sby.git synced 2025-04-06 14:24:08 +00:00

Add localtime to log file

Signed-off-by: Clifford Wolf <clifford@clifford.at>
This commit is contained in:
Clifford Wolf 2018-03-11 01:06:09 +01:00
parent 2c13fbefe6
commit 93752c6fce

View file

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