Apply the filter to the log file
335046
def _analyze(self):
        
        for parsed_line in self.parsed_lines:
            if 'ip' in parsed_line:
                if parsed_line['ip'] in self.filter['ips']:
                    self.noisy_logs.append(parsed_line)
                else:
                    self.quiet_logs.append(parsed_line)
            else:
                self.quiet_logs.append(parsed_line)
233491
def apply_filter(
        filter_fn,
        collection,
        result_fn=None,
        filter_name="",
        collection_name=""):
    
    n_before = len(collection)
    filtered = [x for x in collection if filter_fn(x)]
    n_after = len(filtered)
    if not collection_name:
        collection_name = collection.__class__.__name__
    logging.info(
        "%s filtering removed %d/%d entries of %s",
        filter_name,
        (n_before - n_after),
        n_before,
        collection_name)
    return result_fn(filtered) if result_fn else collection.__class__(filtered)
212785
def apply_filters(target, lines):
    
    filters = get_filters(target)
    if filters:
        for l in lines:
            if any(f in l for f in filters):
                yield l
    else:
        for l in lines:
            yield l
84405
def logging_remove_filter(filter_id, **kwargs):
    
    ctx = Context(**kwargs)
    ctx.execute_action('logging:remove_filter', **{
        'logging_service': ctx.repo.create_secure_service('logging'),
        'filter_id': filter_id,
    })
1103011
def log(self, logfile=None):
        """"""
        if logfile is None:
            logfile = sys.stderr
        tb = self.plaintext.encode('utf-8', 'replace').rstrip() + '\n'
        logfile.write(tb)
503110
function filterFile(file, done) {
      if (files[file].partial) {
        // Discover whether it is explicitly declared as a partial.
        return done(null, files[file].partial)
      } else if (opts.pattern) {
        // Check if it matches the partial pattern.
        return done(null, minimatch(file, opts.pattern))
      }
      // The file is not a partial.
      done(null, false)
    }
511210
def set_logfile(path, instance):
    """"""

    global logfile
    logfile = os.path.normpath(path) + '/hfos.' + instance + '.log'
167738
def apply_filter(self, *args, **kwargs):
        """"""
        if self.filter is not None:
            # make sure self.filter knows about root manual indices
            self.filter.retrieve_manual_indices()

        # Copy event data from hierarchy parent
        self.hparent.apply_filter()
        # update event index
        event_count = np.sum(self.hparent._filter)
        self._events = {}
        self._events["index"] = np.arange(1, event_count + 1)
        # set non-scalar column data
        if "contour" in self.hparent:
            self._events["contour"] = ChildContour(self)
        if "image" in self.hparent:
            self._events["image"] = ChildImage(self)
        if "mask" in self.hparent:
            self._events["mask"] = ChildMask(self)
        if "trace" in self.hparent:
            trdict = {}
            for flname in dfn.FLUOR_TRACES:
                if flname in self.hparent["trace"]:
                    trdict[flname] = ChildTrace(self, flname)
            self._events["trace"] = trdict
        # update config
        self.config["experiment"]["event count"] = event_count

        self._init_filters()
        super(RTDC_Hierarchy, self).apply_filter(*args, **kwargs)
262061
public static synchronized void setLogFilter(LogFilter logFilter) {
        Preconditions.checkArgument(logFilter == null, "logFilter == null");
        Limb.log(LogLevel.DEBUG, "Set LogFilter to instance of class " + logFilter.getClass().getName() + '.');
        LOG_FILTER = logFilter;
    }
1290716
def filter_records(root, head, update, filters=()):
    """"""
    root, head, update = freeze(root), freeze(head), freeze(update)
    for filter_ in filters:
        root, head, update = filter_(root, head, update)

    return thaw(root), thaw(head), thaw(update)
1076888
def grep_log(self, expr, filename='system.log', from_mark=None):
        
        matchings = []
        pattern = re.compile(expr)
        with open(os.path.join(self.get_path(), 'logs', filename)) as f:
            if from_mark:
                f.seek(from_mark)
            for line in f:
                m = pattern.search(line)
                if m:
                    matchings.append((line, m))
        return matchings
725022
def remove_old(self, max_log_time):
        """"""
        files = glob.glob('{}/queue-*'.format(self.log_dir))
        files = list(map(lambda x: os.path.basename(x), files))

        for log_file in files:
            # Get time stamp from filename
            name = os.path.splitext(log_file)[0]
            timestamp = name.split('-', maxsplit=1)[1]

            # Get datetime from time stamp
            time = datetime.strptime(timestamp, '%Y%m%d-%H%M')
            now = datetime.now()

            # Get total delta in seconds
            delta = now - time
            seconds = delta.total_seconds()

            # Delete log file, if the delta is bigger than the specified log time
            if seconds > int(max_log_time):
                log_filePath = os.path.join(self.log_dir, log_file)
                os.remove(log_filePath)
230599
private void loadFilteredPath(String filter) {
        if (filter == null) return;
        filter = getSlashyPath(filter);
        int starIndex = filter.indexOf(WILDCARD);
        if (starIndex == -1) {
            addFile(new File(filter));
            return;
        }
        boolean recursive = filter.contains(ALL_WILDCARD);

        if (filter.lastIndexOf('/') < starIndex) {
            starIndex = filter.lastIndexOf('/') + 1;
        }
        String startDir = filter.substring(0, starIndex - 1);
        File root = new File(startDir);

        filter = Pattern.quote(filter);
        filter = filter.replaceAll("\\" + WILDCARD + "\\" + WILDCARD, MATCH_ALL);
        filter = filter.replaceAll("\\" + WILDCARD, MATCH_FILE_NAME);
        Pattern pattern = Pattern.compile(filter);

        final File[] files = root.listFiles();
        if (files != null) {
            findMatchingFiles(files, pattern, recursive);
        }
    }
1173212
protected function processLogFile ()
	{
		$this->logFile = (empty($this->logFile)) ? $this->logDir.strtolower($this->level)."Log.txt" : $this->logDir.$this->logFile;
		return $this;
	}
635618
def _load_file(self, log_file, message_name_filter_list):
        
        if isinstance(log_file, str):
            self._file_handle = open(log_file, "rb")
        else:
            self._file_handle = log_file

        # parse the whole file
        self._read_file_header()
        self._last_timestamp = self._start_timestamp
        self._read_file_definitions()

        if self.has_data_appended and len(self._appended_offsets) > 0:
            if self._debug:
                print('This file has data appended')
            for offset in self._appended_offsets:
                self._read_file_data(message_name_filter_list, read_until=offset)
                self._file_handle.seek(offset)

        # read the whole file, or the rest if data appended
        self._read_file_data(message_name_filter_list)

        self._file_handle.close()
        del self._file_handle
1013746
def apply_filters prev_filters = nil, filter_codecs = nil
      prev_filters = filter_types if prev_filters.nil?
      filter_codecs = [] if filter_codecs.nil?
      current_filters = []
      prev = nil
      line_sizes = []
      scanline_positions.push(@filtered_data.size).inject do |m, n|
        line_sizes << n - m - 1
        n
      end
      wrap_with_rewind(@filtered_data) do
        # decode all scanlines
        prev_filters.each_with_index do |type, i|
          byte = @filtered_data.read 1
          current_filters << byte.unpack('C').first
          line_size = line_sizes[i]
          line = @filtered_data.read line_size
          filter = Filter.new type, @sample_size
          if filter_codecs[i] && filter_codecs[i][:decoder]
            filter.decoder = filter_codecs[i][:decoder]
          end
          if !prev.nil? && @interlace_pass_count.include?(i + 1)  # make sure prev to be nil if interlace pass is changed
            prev = nil
          end
          decoded = filter.decode line, prev
          @filtered_data.pos -= line_size
          @filtered_data << decoded
          prev = decoded
        end
        # encode all
        filter_codecs.reverse!
        line_sizes.reverse!
        data_amount = @filtered_data.pos # should be eof
        ref = data_amount
        current_filters.reverse_each.with_index do |type, i|
          line_size = line_sizes[i]
          ref -= line_size + 1
          @filtered_data.pos = ref + 1
          line = @filtered_data.read line_size
          prev = nil
          if !line_sizes[i + 1].nil?
            @filtered_data.pos = ref - line_size
            prev = @filtered_data.read line_size
          end
          # make sure prev to be nil if interlace pass is changed
          if @interlace_pass_count.include?(current_filters.size - i)
            prev = nil
          end
          filter = Filter.new type, @sample_size
          if filter_codecs[i] && filter_codecs[i][:encoder]
            filter.encoder = filter_codecs[i][:encoder]
          end
          encoded = filter.encode line, prev
          @filtered_data.pos = ref + 1
          @filtered_data << encoded
        end
      end
    end
864395
def _adjust_log_file_override(overrides, default_log_file):
    '''
    
    '''
    if overrides.get('log_dir'):
        # Adjust log_file if a log_dir override is introduced
        if overrides.get('log_file'):
            if not os.path.isabs(overrides['log_file']):
                # Prepend log_dir if log_file is relative
                overrides['log_file'] = os.path.join(overrides['log_dir'],
                                                     overrides['log_file'])
        else:
            # Create the log_file override
            overrides['log_file'] = \
                os.path.join(overrides['log_dir'],
                             os.path.basename(default_log_file))