fifolog.py

Sun, 21 Jan 2018 23:52:35 +0000

author
Tuomo Valkonen <tuomov@iki.fi>
date
Sun, 21 Jan 2018 23:52:35 +0000
changeset 45
aa2a95dc6093
parent 35
495a510a6d01
permissions
-rw-r--r--

Further improvements to state reporting; indicate busyness if repository lock cannot be acquired

#
# 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