1 # Copyright 2018 ke liang <lokyse@163.com>.
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
16 from logging import Filter
17 from .marker import matchMarkerHelp
20 class MarkerFilter(Filter):
22 def __init__(self, name="", markers=None):
23 if sys.version_info > (2, 7):
24 super(MarkerFilter, self).__init__(name)
26 Filter.__init__(self, name)
28 self.markerToMatch = markers
30 def filter(self, record):
31 # compare filter's markers with record's marker
32 return matchMarkerHelp(record, self.markerToMatch)