From 0975e3186a8aa83e3496f4e6891c8d934bee3d5f Mon Sep 17 00:00:00 2001 From: asteroide Date: Tue, 1 Dec 2015 15:49:18 +0100 Subject: Add date and time in log files. Change-Id: I07a148c01afcab0330e4d95d118439635908013d --- moonclient/moonclient/tests.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/moonclient/moonclient/tests.py b/moonclient/moonclient/tests.py index fb4daa69..3bef6b9d 100644 --- a/moonclient/moonclient/tests.py +++ b/moonclient/moonclient/tests.py @@ -23,9 +23,14 @@ class TestsLaunch(Lister): result_vars = dict() logfile_name = "/tmp/moonclient_test_{}.log".format(time.strftime("%Y%m%d-%H%M%S")) logfile = open(logfile_name, "w") + TIME_FORMAT = '%Y-%m-%d %H:%M:%S' def get_parser(self, prog_name): parser = super(TestsLaunch, self).get_parser(prog_name) + parser.add_argument( + '--stop-on-error', + help='Stop the test on the first error', + ) parser.add_argument( 'testfile', metavar='', @@ -130,7 +135,7 @@ class TestsLaunch(Lister): if port: title += ":" + port title += "\n" - self.logfile.write(title + "\n") + self.logfile.write(time.strftime(self.TIME_FORMAT) + " " + title + "\n") self.log.info(title) data_tmp = list() data_tmp.append("") @@ -149,7 +154,7 @@ class TestsLaunch(Lister): else: continue ext_command = self.__replace_var_in_str(ext_command) - self.logfile.write("-----> {}\n".format(ext_command)) + self.logfile.write(time.strftime(self.TIME_FORMAT) + " " + "-----> {}\n".format(ext_command)) self.log.info(" \\-executing external \"{}\"".format(ext_command)) pipe = subprocess.Popen(shlex.split(ext_command), stdout=subprocess.PIPE, stderr=subprocess.PIPE) com = pipe.communicate() @@ -163,7 +168,7 @@ class TestsLaunch(Lister): else: command = test["command"] + " " + global_command_options command = self.__replace_var_in_str(command) - self.logfile.write("-----> {}\n".format(command)) + self.logfile.write(time.strftime(self.TIME_FORMAT) + " " + "-----> {}\n".format(command)) self.log.info(" \\-executing {}".format(command)) self.app.stdout = tmp_filename_fd result_id = self.app.run_subcommand(shlex.split(command)) -- cgit 1.2.3-korg