Changeset 8516


Ignore:
Timestamp:
25 May 2012, 02:02:44 (12 years ago)
Author:
uli
Message:

Exclude backup files by default when listing logfiles.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/datacenter.py

    r8513 r8516  
    3535
    3636#: Regular expression describing a logfile name with backup extension
    37 RE_LOGFILE_NAME = re.compile('^.+\.\d+$')
     37RE_LOGFILE_BACKUP_NAME = re.compile('^.+\.\d+$')
    3838
    3939class DataCenter(grok.Container, Logger):
     
    8585        return result
    8686
    87     def getLogFiles(self):
     87    def getLogFiles(self, exclude_backups=True):
    8888        """Get the files from logs/ subdir. Files are sorted by name.
     89
     90        By default backup logs ('app.log.1', etc.) are excluded.
    8991        """
    9092        result = []
     
    9496        for name in sorted(os.listdir(logdir)):
    9597            if not os.path.isfile(os.path.join(logdir, name)):
     98                continue
     99            if exclude_backups == True and RE_LOGFILE_BACKUP_NAME.match(name):
    96100                continue
    97101            result.append(
     
    203207        files = [basename,]
    204208        for name in os.listdir(os.path.join(self.storage, 'logs')):
    205             if RE_LOGFILE_NAME.match(name):
     209            if RE_LOGFILE_BACKUP_NAME.match(name):
    206210                files.append(name)
    207211        return sorted(files, key=numerical_suffix)
Note: See TracChangeset for help on using the changeset viewer.