コード例 #1
0
    def filter(self, record):
        record.sampled = ServiceContext.sampled
        record.trace_id = ServiceContext.trace_id
        record.span_id = ServiceContext.span_id
        record.request_id = ServiceContext.request_id
        record.component = ServiceContext.component_name

        return Filter.filter(self, record)
コード例 #2
0
ファイル: loggers.py プロジェクト: mrjmad/creme_crm-2.1
    def filter(self, record):
        if Filter.filter(self, record) == 0:
            return 0

        if self.pattern:
            match = self.pattern.match(record.getMessage()) is not None
            match = not match if self.exclude else match
            return 1 if match else 0

        return 1
コード例 #3
0
def fileLogging(fname):
    """
    Remove all StreamHandlers;
    Add a single FileHandler (filename given as arg);
    Add a filter to omit dots.

    """
    def dotfilter(record):
        if record.msg.strip() != '.':
            return True
    logfilter = Filter()
    logfilter.filter = dotfilter

    fhandler = FileHandler(fname, 'w')
    for logger in list(_loggers.values()):
        for handler in logger.handlers:
            logger.removeHandler(handler)
        logger.addHandler(fhandler)
        logger.addFilter(logfilter)
コード例 #4
0
ファイル: Logging.py プロジェクト: EHCliffe/plastex
def fileLogging(fname):
    """
    Remove all StreamHandlers;
    Add a single FileHandler (filename given as arg);
    Add a filter to omit dots.

    """
    def dotfilter(record):
        if record.msg.strip() != '.':
            return True
    logfilter = Filter()
    logfilter.filter = dotfilter

    fhandler = FileHandler(fname, 'w')
    for logger in _loggers.values():
        for handler in logger.handlers:
            logger.removeHandler(handler)
        logger.addHandler(fhandler)
        logger.addFilter(logfilter)
コード例 #5
0
ファイル: Filter.py プロジェクト: dionysusxie/python
class Filter:

    def __init__(self):
        self.blocked = []

    def filter(self, sequence):
        return [x for x in sequence if x not in self.blocked]


class SPAM_Filter(Filter):
    def __init__(self):
        self.blocked = ['SPAM']


f = Filter()
print f.filter([1, 2, 3])

s = SPAM_Filter()
s_list = ['SPAM', 'SPAM', 'ONE', 'spam']
print 'Origin list:', s_list
print 'List after filtering with SPAM:', s.filter(s_list)


# issubclass()
if issubclass(SPAM_Filter, Filter):
    print 'SPAM_Filter is a subclass of Filter.'
else:
    print 'SPAM_Filter is NOT a subclass of Filter.'

# __bases__
print 'Superclasses of SPAM_Filter: ' + str(SPAM_Filter.__bases__)