X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Flogger.py;h=419b878642ab5215bd87aa3b7f313055d974bd80;hb=c4e054afd81228a895d6bccc5d25f61cd4c46592;hp=3e1e5a1ab3e9d36b1e8e8812712b8bb6f3ee6724;hpb=1f02c81118d5a867fa34056b79b2433620899a10;p=tools%2Fsat.git diff --git a/src/logger.py b/src/logger.py index 3e1e5a1..419b878 100644 --- a/src/logger.py +++ b/src/logger.py @@ -32,7 +32,11 @@ logCommandFileExpression = "^[0-9]{8}_+[0-9]{6}_+.*\.xml$" class Logger(object): '''Class to handle log mechanism. ''' - def __init__(self, config, silent_sysstd=False, all_in_terminal=False): + def __init__(self, + config, + silent_sysstd=False, + all_in_terminal=False, + micro_command = False): '''Initialization :param config pyconf.Config: The global configuration. @@ -44,12 +48,16 @@ class Logger(object): self.silentSysStd = silent_sysstd # Construct xml log file location for sat prints. - logFileName = config.VARS.datehour + "_" + config.VARS.command + ".xml" - logFilePath = os.path.join(config.SITE.log.log_dir, logFileName) + prefix = "" + if micro_command: + prefix = "micro_" + hour_command = config.VARS.datehour + "_" + config.VARS.command + logFileName = prefix + hour_command + ".xml" + logFilePath = os.path.join(config.USER.log_dir, logFileName) # Construct txt file location in order to log # the external commands calls (cmake, make, git clone, etc...) - txtFileName = config.VARS.datehour + "_" + config.VARS.command + ".txt" - txtFilePath = os.path.join(config.SITE.log.log_dir, "OUT", txtFileName) + txtFileName = prefix + hour_command + ".txt" + txtFilePath = os.path.join(config.USER.log_dir, "OUT", txtFileName) src.ensure_path_exists(os.path.dirname(logFilePath)) src.ensure_path_exists(os.path.dirname(txtFilePath)) @@ -164,6 +172,7 @@ class Logger(object): else: if self.default_level <= current_output_verbose_level and not self.silentSysStd: sys.stdout.write(message) + self.flush() def error(self, message): '''Print an error. @@ -218,7 +227,7 @@ class Logger(object): self.xmlFile.write_tree(stylesheet = "command.xsl") # Dump the config in a pyconf file in the log directory - logDir = self.config.SITE.log.log_dir + logDir = self.config.USER.log_dir dumpedPyconfFileName = (self.config.VARS.datehour + "_" + self.config.VARS.command @@ -278,7 +287,12 @@ def show_command_log(logFilePath, cmd, application, notShownCommands): return False, None # Get the application of the log file - logFileXml = src.xmlManager.ReadXmlFile(logFilePath) + try: + logFileXml = src.xmlManager.ReadXmlFile(logFilePath) + except Exception as e: + msg = _("WARNING: the log file %s cannot be read:" % logFilePath) + sys.stdout.write(printcolors.printcWarning("%s\n%s\n" % (msg, e))) + return False, None if 'application' in logFileXml.xmlroot.keys(): appliLog = logFileXml.xmlroot.get('application')