Ejemplo n.º 1
0
    def log(self, logvalues, level='INFO'):
        if len(logvalues):
            log = []
            for name in self._log.mapping:
                if name == 'time':
                    log.append(self._sh.now())
                elif name == 'thread':
                    log.append(threading.current_thread().name)
                elif name == 'level':
                    log.append(level)
                else:
                    values_txt = map(str, logvalues)
                    log.append(' '.join(values_txt))
            self._log.add(log)
            if self._logtofile is True:
                self.update_logfilename()
                self.__myLogger.info('{}: {}', log[2], ''.join(log[3:]))

            if self._cache is True:
                try:
                    _cache_write(self.logger, self._cachefile,
                                 self._log.export(int(self._maxlen)))
                except Exception as e:
                    self.logger.warning(
                        "OperationLog {}: could not update cache {}".format(
                            self._path, e))
Ejemplo n.º 2
0
    def log(self, logvalues, level='INFO'):
        """
        Creates a log entry with logvalues of given level
        """
        if len(logvalues):
            log = []
            for name in self._log.mapping:
                if name == 'time':
                    log.append(self.shtime.now())
                elif name == 'thread':
                    log.append(threading.current_thread().name)
                elif name == 'level':
                    log.append(level)
                else:
                    values_txt = map(str, logvalues)
                    log.append(' '.join(values_txt))
            self._log.add(log)
            # consider to write the log entry to 
            if self._logtofile:
                self.update_logfilename()
                self.__myLogger.info('{}: {}', log[2], ''.join(log[3:]))

            if self._cache is True:
                try:
                    _cache_write(self.logger, self._cachefile, self._log.export(int(self._maxlen)))
                except Exception as e:
                    self.logger.warning("OperationLog {}: could not update cache {}".format(self._path, e))

            if self.additional_logger:
                self.additional_logger.log(logging.getLevelName(level), ' '.join(map(str, logvalues)))
Ejemplo n.º 3
0
 def load(self, logentries):
     if len(logentries) != 0:
         for logentry in reversed(logentries):
             log = []
             for name in self._log.mapping:
                 if name == 'time':
                     log.append(logentry['time'])
                 elif name == 'thread':
                     log.append(logentry['thread'])
                 elif name == 'level':
                     log.append(logentry['level'])
                 elif name == 'message':
                     log.append(logentry['message'])
             self._log.add(log)
Ejemplo n.º 4
0
 def load(self, logentries):
     if len(logentries) != 0:
         for logentry in reversed(logentries):
             log = []
             for name in self._log.mapping:
                 if name == 'time':
                     log.append(logentry['time'])
                 elif name == 'thread':
                     log.append(logentry['thread'])
                 elif name == 'level':
                     log.append(logentry['level'])
                 elif name == 'message':
                     log.append(logentry['message'])
             self._log.add(log)
Ejemplo n.º 5
0
    def log(self, logvalues, level='INFO'):
        if len(logvalues):
            log = []
            for name in self._log.mapping:
                if name == 'time':
                    log.append(self._sh.now())
                elif name == 'thread':
                    log.append(threading.current_thread().name)
                elif name == 'level':
                    log.append(level)
                else:
                    log.append(logvalues[0])
                    logvalues = logvalues[1:]

            self._log.add(log)
Ejemplo n.º 6
0
    def log(self, logvalues, level = 'INFO'):
        if len(logvalues):
            log = []
            for name in self._log.mapping:
                if name == 'time':
                    log.append(self._sh.now())
                elif name == 'thread':
                    log.append(threading.current_thread().name)
                elif name == 'level':
                    log.append(level)
                else:
                    log.append(logvalues[0])
                    logvalues = logvalues[1:]

            self._log.add(log)
Ejemplo n.º 7
0
 def log(self, logvalues, level='INFO'):
     if len(logvalues):
         log = []
         for name in self._log.mapping:
             if name == 'time':
                 log.append(self._sh.now())
             elif name == 'thread':
                 log.append(threading.current_thread().name)
             elif name == 'level':
                 log.append(level)
             else:
                 values_txt = map(str, logvalues)
                 log.append(' '.join(values_txt))
         self._log.add(log)
         if self._logtofile is True:
             self.update_logfilename()
             self.__myLogger.info('{}: {}', log[2], ''.join(log[3:]))
Ejemplo n.º 8
0
 def load(self, logentries):
     """
     Loads logentries (which were just read from cache) into the log object (see lib.log.Log())
     """
     if len(logentries) != 0:
         for logentry in reversed(logentries):
             log = []
             for name in self._log.mapping:
                 if name == 'time':
                     log.append(logentry['time'])
                 elif name == 'thread':
                     log.append(logentry['thread'])
                 elif name == 'level':
                     log.append(logentry['level'])
                 elif name == 'message':
                     log.append(logentry['message'])
             self._log.add(log)
Ejemplo n.º 9
0
 def log(self, logvalues, level='INFO'):
     if len(logvalues):
         log = []
         for name in self._log.mapping:
             if name == 'time':
                 log.append(self._sh.now())
             elif name == 'thread':
                 log.append(threading.current_thread().name)
             elif name == 'level':
                 log.append(level)
             else:
                 values_txt = map(str, logvalues)
                 log.append(' '.join(values_txt))
         self._log.add(log)
         if self._logtofile is True:
             self.update_logfilename()
             self.__myLogger.info('{}: {}', log[2], ''.join(log[3:]))