class Sawmill::EntryProcessor::And

A boolean processor that returns true if and only if all its child processors return true. This version short-circuits the processing, so once one child returns false, subsequent children are not called at all.

For example, this builds a processor that sends formatted log entries to STDOUT only if their level is at least INFO AND the progname is is “rails”:

processor = Sawmill::EntryProcessor.build do
  If(And(FilterByBasicFields(:level => :INFO),
         FilterByBasicFields(:progname => 'rails')),
     Format(STDOUT))
end

Public Class Methods

new(*children_) click to toggle source

Create an “and” boolean. The parameters are child processors whose return values should be combined with an AND operation.

# File lib/sawmill/entry_processor/conditionals.rb, line 190
def initialize(*children_)
  @children = _interpret_processor_array(children_)
end

Public Instance Methods

attribute(entry_) click to toggle source
# File lib/sawmill/entry_processor/conditionals.rb, line 215
def attribute(entry_)
  @children.each do |child_|
    return false unless child_.attribute(entry_)
  end
  true
end
begin_record(entry_) click to toggle source
# File lib/sawmill/entry_processor/conditionals.rb, line 194
def begin_record(entry_)
  @children.each do |child_|
    return false unless child_.begin_record(entry_)
  end
  true
end
end_record(entry_) click to toggle source
# File lib/sawmill/entry_processor/conditionals.rb, line 201
def end_record(entry_)
  @children.each do |child_|
    return false unless child_.end_record(entry_)
  end
  true
end
finish() click to toggle source
# File lib/sawmill/entry_processor/conditionals.rb, line 229
def finish
  Util::ProcessorTools.collect_finish_values(@children)
end
message(entry_) click to toggle source
# File lib/sawmill/entry_processor/conditionals.rb, line 208
def message(entry_)
  @children.each do |child_|
    return false unless child_.message(entry_)
  end
  true
end
unknown_data(entry_) click to toggle source
# File lib/sawmill/entry_processor/conditionals.rb, line 222
def unknown_data(entry_)
  @children.each do |child_|
    return false unless child_.unknown_data(entry_)
  end
  true
end