Пример #1
0
 def has_log(self):
     if self._get_oldest_index() > 0:
         return True
     else:
         # allow for a return, it's a little arbitrary.
         return True if file_size(self.current_log_file) > 1 \
                 else False
Пример #2
0
 def add_log(self, msg):
     '''
     Interface to write log.
     '''
     with self.handle_lock:
         if file_size(self.current_log_file) + len(msg) \
                 > self.max_file_size:
             new_backup_filename = self._generate_next_filename()
             shutil.move(self.current_log_file,
                     os.path.join(self.folder, new_backup_filename))
         with open(self.current_log_file, 'a') as f:
             f.write("%s\n" % msg)