fifolog.py

Fri, 26 Jan 2018 19:04:04 +0000

author
Tuomo Valkonen <tuomov@iki.fi>
date
Fri, 26 Jan 2018 19:04:04 +0000
changeset 74
4f56142e7497
parent 35
495a510a6d01
permissions
-rw-r--r--

Separated repository configuration form backup configuration;
gave passphrase management to Repository object;
various fixes.

#
# FIFO memory logger
#

from logging.handlers import BufferingHandler

class FIFOHandler(BufferingHandler):
    def shouldFlush(self, record):
        return False

    def emit(self, record):
        self.buffer.append(record)
        l=len(self.buffer)
        if l>self.capacity:
            self.buffer=self.buffer[(l-self.capacity):(l-1)]

    def formatAll(self):
        return [self.format(record) for record in self.buffer]

mercurial