fifolog.py

changeset 34
9fce700d42de
child 35
495a510a6d01
equal deleted inserted replaced
33:91421eeb4426 34:9fce700d42de
1 #
2 # FIFO memory logger
3 #
4
5 from logging.handlers import BufferingHandler
6
7 class FIFOHandler(BufferingHandler):
8 def shouldFlush(self, record):
9 return False
10
11 def emit(self, record):
12 self.buffer.append(record)
13 l=len(self.buffer)
14 if l>self.capacity:
15 self.buffer=self.buffer[(l-self.capacity+1):l]
16
17 def formatAll(self):
18 return [self.format(record) for record in self.buffer]

mercurial