79:b075b3db3044 | 80:a409242121d5 |
---|---|
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):(l-1)] | |
16 | |
17 def formatAll(self): | |
18 return [self.format(record) for record in self.buffer] |