Skip to content

Commit

Permalink
replace NoMatchMatch: a plugin (out_reemit) uses it...
Browse files Browse the repository at this point in the history
  • Loading branch information
tagomoris committed Jan 10, 2017
1 parent e313703 commit 1705933
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 37 deletions.
37 changes: 37 additions & 0 deletions lib/fluent/event_router.rb
Original file line number Diff line number Diff line change
Expand Up @@ -266,4 +266,41 @@ def find(tag)
end
end
end

class NoMatchMatch
def initialize(log)
@log = log
@count = 0
@warn_not_matched = true
end

def suppress_missing_match!
# for <label @FLUENT_LOG>
@warn_not_matched = false
end

def emit_events(tag, es)
return unless @warn_not_matched
# TODO use time instead of num of records
c = (@count += 1)
if c < 512
if Math.log(c) / Math.log(2) % 1.0 == 0
@log.warn "no patterns matched", tag: tag
return
end
else
if c % 512 == 0
@log.warn "no patterns matched", tag: tag
return
end
end
@log.on_trace { @log.trace "no patterns matched", tag: tag }
end

def start
end

def shutdown
end
end
end
37 changes: 0 additions & 37 deletions lib/fluent/match.rb
Original file line number Diff line number Diff line change
Expand Up @@ -138,41 +138,4 @@ def match(str)
@patterns.any? {|pattern| pattern.match(str) }
end
end

class NoMatchMatch
def initialize(log)
@log = log
@count = 0
@warn_not_matched = true
end

def suppress_missing_match!
# for <label @FLUENT_LOG>
@warn_not_matched = false
end

def emit_events(tag, es)
return unless @warn_not_matched
# TODO use time instead of num of records
c = (@count += 1)
if c < 512
if Math.log(c) / Math.log(2) % 1.0 == 0
@log.warn "no patterns matched", tag: tag
return
end
else
if c % 512 == 0
@log.warn "no patterns matched", tag: tag
return
end
end
@log.on_trace { @log.trace "no patterns matched", tag: tag }
end

def start
end

def shutdown
end
end
end

0 comments on commit 1705933

Please sign in to comment.