Changeset 8592


Ignore:
Timestamp:
1 Jun 2012, 12:30:57 (12 years ago)
Author:
Henrik Bettermann
Message:

Search log files in chronological order.

Location:
main/waeup.kofa/trunk/src/waeup/kofa
Files:
2 edited

Legend:

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

    r8516 r8592  
    209209            if RE_LOGFILE_BACKUP_NAME.match(name):
    210210                files.append(name)
    211         return sorted(files, key=numerical_suffix)
     211        return sorted(files, key=numerical_suffix, reverse=True)
    212212
    213213    def queryLogfiles(self, basename, query=None, limit=0, start=0):
     
    220220        All logfiles with name `basename` and maybe some numerical
    221221        extension ('.1', '.2', ...) are searched for the `query` term
    222         in correct order. So, if you ask for a basename 'app.log',
    223         then any file named 'app.log', 'app.log.1', 'app.log.2',
     222        in correct chronological order. So, if you ask for a basename 'app.log',
     223        then any file named 'app2.log', 'app.log.1', 'app.log',
    224224        etc. will be searched in that order.
    225225
  • main/waeup.kofa/trunk/src/waeup/kofa/tests/test_datacenter.py

    r8517 r8592  
    3636        # write 100 messages into logfile, with 50 containing 'Msg'
    3737        path = self.logpath
    38         for m in range(num):
     38        for m in range(num-1,-1,-1):
    3939            fp = open(path, 'wb')
    4040            for n in range(50*m, 50*m+50):
     
    6262        # We can find entries in multiple logfiles (backups)
    6363        datacenter = DataCenter()
    64         open(self.logpath, 'wb').write('Msg 1\n')
     64        open(self.logpath, 'wb').write('Msg 3\n')
    6565        open(self.logpath + '.2', 'wb').write('Msg 2\n')
    66         open(self.logpath + '.10', 'wb').write('Msg 3\n')
     66        open(self.logpath + '.10', 'wb').write('Msg 1\n')
    6767        result = list(datacenter.queryLogfiles('myapp.log', 'Msg'))
    6868        # entry of logfile .10 comes after entry of logfile .2
Note: See TracChangeset for help on using the changeset viewer.