class LogTools::PostProcessing::LogStreamMatcher
Attributes
annotation_ranges[R]
log_file_matcher[R]
stream_name_matcher[R]
stream_type_matcher[R]
Public Class Methods
new()
click to toggle source
# File lib/log_tools/post_processing.rb, line 401 def initialize @annotation_ranges = Array.new end
Public Instance Methods
annotated_region(ann_start, ann_end)
click to toggle source
# File lib/log_tools/post_processing.rb, line 420 def annotated_region(ann_start, ann_end) if !ann_start.respond_to?(:match) ann_start = AnnotationMatcher.new(ann_start) end if !ann_end.respond_to?(:match) ann_end = AnnotationMatcher.new(ann_end) end annotation_ranges << [ann_start, ann_end] self end
filters_logfiles?()
click to toggle source
# File lib/log_tools/post_processing.rb, line 448 def filters_logfiles? !!log_file_matcher end
filters_streams?()
click to toggle source
# File lib/log_tools/post_processing.rb, line 462 def filters_streams? !!(stream_name_matcher || stream_type_matcher) end
logfile(matcher)
click to toggle source
# File lib/log_tools/post_processing.rb, line 415 def logfile(matcher) @log_file_matcher = matcher self end
matches_logfile?(path)
click to toggle source
# File lib/log_tools/post_processing.rb, line 452 def matches_logfile?(path) if log_file_matcher === path if filters_streams? nil else true end else false end end
matches_stream?(stream)
click to toggle source
# File lib/log_tools/post_processing.rb, line 466 def matches_stream?(stream) if stream_name_matcher && !(stream_name_matcher === stream.name) false elsif stream_type_matcher && !(stream_type_matcher === stream.type.name) false elsif stream_name_matcher || stream_type_matcher true else nil end end
matching_regions(stream, annotations)
click to toggle source
Calls superclass method
LogTools::PostProcessing::Matcher#matching_regions
# File lib/log_tools/post_processing.rb, line 477 def matching_regions(stream, annotations) if annotation_ranges.empty? return super end regions = Array.new region_start, current_ann_start, current_ann_end = nil annotations.each do |ann| if region_start && current_ann_end.match(stream, ann) regions << Region.new(region_start, ann.time) region_start = nil end annotation_ranges.each do |ann_start, ann_end| next if !ann_start.match(stream, ann) if region_start ann_value = ann.value.split("\n").join("\\n") if ann_value.length > 10 ann_value = ann_value[0, 10] + "..." end ann_to_s = "annotation(#{ann.time}, key:#{ann.key}, stream:#{ann.stream_name}, value:#{ann_value})" LogTools.warn "found #{ann_to_s} within an already opened region matched by #{current_ann_start}:#{current_ann_end}, dropping the current region" end region_start = ann.time current_ann_start = ann_start current_ann_end = ann_end end end regions end
stream_name(matcher)
click to toggle source
# File lib/log_tools/post_processing.rb, line 405 def stream_name(matcher) @stream_name_matcher = matcher self end
stream_type(matcher)
click to toggle source
# File lib/log_tools/post_processing.rb, line 410 def stream_type(matcher) @stream_type_matcher = matcher self end
to_s()
click to toggle source
# File lib/log_tools/post_processing.rb, line 431 def to_s result = Array.new if filters_logfiles? result << "logfile(#{log_file_matcher})" end if stream_name_matcher result << "stream_name(#{stream_name_matcher})" end if stream_type_matcher result << "stream_type(#{stream_type_matcher})" end annotation_ranges.each do |s, e| result << "annotation_ranges(#{s}, #{e})" end result.join(".") end