borgend/fifolog.py

Tue, 21 Apr 2020 09:59:51 -0500

author
Tuomo Valkonen <tuomov@iki.fi>
date
Tue, 21 Apr 2020 09:59:51 -0500
changeset 129
9f3ae6b3133f
parent 89
51cc2e25af38
permissions
-rw-r--r--

Improve installation instructions;
move py2app to keychain configuration section.

#
# Borgend by Tuomo Valkonen, 2018
#
# This is a simple limited memory FIFO log for the logging module
#

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