borgend/fifolog.py

Mon, 17 Sep 2018 19:48:02 -0500

author
Tuomo Valkonen <tuomov@iki.fi>
date
Mon, 17 Sep 2018 19:48:02 -0500
changeset 118
aadd60a24bc8
parent 89
51cc2e25af38
permissions
-rw-r--r--

py2app is fucked up shit that couldn't find a packages with staring at it
with its name written on it, and instead takes them all, so include a long
list of modules to forcibly exclude to build a reasonably-sized app.

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