Class: Fluent::ScribeInput::FluentScribeHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/fluent/plugin/in_scribe.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#add_prefixObject

Returns the value of attribute add_prefix.



123
124
125
# File 'lib/fluent/plugin/in_scribe.rb', line 123

def add_prefix
  @add_prefix
end

#ignore_invalid_recordObject

Returns the value of attribute ignore_invalid_record.



126
127
128
# File 'lib/fluent/plugin/in_scribe.rb', line 126

def ignore_invalid_record
  @ignore_invalid_record
end

#loggerObject

Use logger instead of log to avoid confusion with Log method



127
128
129
# File 'lib/fluent/plugin/in_scribe.rb', line 127

def logger
  @logger
end

#msg_formatObject

Returns the value of attribute msg_format.



125
126
127
# File 'lib/fluent/plugin/in_scribe.rb', line 125

def msg_format
  @msg_format
end

#remove_newlineObject

Returns the value of attribute remove_newline.



124
125
126
# File 'lib/fluent/plugin/in_scribe.rb', line 124

def remove_newline
  @remove_newline
end

Instance Method Details

#Log(msgs) ⇒ Object



129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# File 'lib/fluent/plugin/in_scribe.rb', line 129

def Log(msgs)
  begin
    msgs.each { |msg|
      begin
        record = create_record(msg)
      rescue => e
        if @ignore_invalid_record
          # This warning can be disabled by 'log_level error'
          logger.warn "got invalid record: #{msg}"
          next
        else
          # Keep existence behaviour
          raise e
        end
      end

      if @add_prefix
        Engine.emit(@add_prefix + '.' + msg.category, Engine.now, record)
      else
        Engine.emit(msg.category, Engine.now, record)
      end
    }
    return ResultCode::OK
  rescue => e
    logger.error "unexpected error", :error => e.inspect
    logger.error_backtrace
    return ResultCode::TRY_LATER
  end
end