def rotate(self): """Rotate the current logfile. Also remove extra entries and compress the last ones. """ # Rotate the log daily. DailyLogFile.rotate(self) # Remove 'extra' rotated log files. logs = self.listLogs() for log_path in logs[self.maxRotatedFiles:]: os.remove(log_path) # Refresh the list of existing rotated logs logs = self.listLogs() # Skip compressing if there are no files to be compressed. if len(logs) <= self.compressLast: return # Compress last log files. for log_path in logs[-self.compressLast:]: # Skip already compressed files. if log_path.endswith('bz2'): continue self._compressFile(log_path)
def rotate(self): DailyLogFile.rotate(self) dir = os.path.dirname(self.path) files = os.listdir(dir) for file in files: if file.startswith("honeypy.log."): os.remove(os.path.join(dir, file))
def rotate(self): """ Rotate the file and create a new one. If it's not possible to open new logfile, this will fail silently, and continue logging to old logfile. Old log files will be automatically purged. """ #daily rotation first DailyLogFile.rotate(self) if not self.maxRotatedFiles: return if not (os.access(self.directory, os.W_OK) and os.access(self.path, os.W_OK)): return logs = self.listLogs() while len(logs) >= self.maxRotatedFiles: l = logs.pop(0) #this should never match, but just make sure if l.endswith('log'): continue self.notification('deleting %s' % l) os.remove(l)
def rotate(self): DailyLogFile.rotate(self) self.delete_old_logs()