Coverage for mtools.mlogfilter.filters.mask_filter : 94%

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
""" This filter takes an argument `--mask <LOGFILE>` and another optional argument `--mask-size <SECS>`. It will read <LOGFILE> and for each of the lines extract the datetimes (let's call these "events"). It will add some padding for each of these events, <SECS>/2 seconds on either side. MaskFilter will then accept every line from the original log file (different to <LOGFILE>), that lies within one of these masked intervals.
This feature is very useful to find all correlating lines to certain events.
For example, find all assertions in a log file, then find all log lines surrounding these assertions:
grep "assert" mongod.log > assertions.log mlogfilter mongod.log --mask assertions.log --mask-size 60
"""
('--mask', {'action':'store', 'type':InputSourceAction(), 'help':'source (log file or system.profile db) to create the filter mask.'}), ('--mask-size', {'action':'store', 'type':int, 'default':60, 'help':'mask size in seconds around each filter point (default: 60 secs, 30 on each side of the event)'}), ('--mask-center', {'action':'store', 'choices':['start', 'end', 'both'], 'default':'end', 'help':'mask center point for events with duration (default: end). If both is chosen, all events from start to end are returned.'}) ]
""" constructor, init superclass and mark this filter active if `mask` argument is present. """
""" create mask list consisting of all tuples between which this filter accepts lines. """
# get start and end of the mask and set a start_limit raise SystemExit("Can't parse format of %s. Is this a log file or system.profile collection?" % self.mlogfilter.args['mask'])
# load filter mask file
# define start and end of total mask
# consider --mask-center
self.mask_end -= timedelta(milliseconds=logevent_list[-1].duration)
# different center points
return
end_point = (e[1] if type(e) == tuple else e) + self.mask_half_td else:
else:
""" overwrite this method in subclass and return True if the provided logevent should be accepted (causing output), or False if not. """
""" overwrite this method in sublcass and return True if all lines from here to the end of the file should be rejected (no output). """
|