Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

from base_filter import BaseFilter 

 

class SlowFilter(BaseFilter): 

    """ accepts only lines that have a duration that is longer than the specified  

        parameter in ms (default 1000). 

    """ 

    filterArgs = [ 

        ('--slow', {'action':'store', 'nargs':'?', 'default':False, 'type':int, 'help':'only output lines with query times longer than SLOW ms (default 1000)'}) 

    ] 

 

    def __init__(self, mlogfilter): 

        BaseFilter.__init__(self, mlogfilter) 

 

        if 'slow' in self.mlogfilter.args and self.mlogfilter.args['slow'] != False: 

            self.active = True 

            if self.mlogfilter.args['slow'] == None: 

                self.slowms = 1000 

            else: 

                self.slowms = self.mlogfilter.args['slow'] 

 

    def accept(self, logevent): 

        if logevent.duration: 

            return logevent.duration >= self.slowms 

        return False