Class: LogStash::Inputs::Base

Inherits:
Plugin
  • Object
show all
Includes:
Config::Mixin
Defined in:
lib/logstash/inputs/base.rb

Overview

This is the base class for logstash inputs.

Constant Summary

Constants included from Config::Mixin

Config::Mixin::CONFIGSORT

Instance Attribute Summary collapse

Attributes included from Config::Mixin

#config, #original_params

Attributes inherited from Plugin

#logger

Instance Method Summary collapse

Methods included from Config::Mixin

#config_init, included

Methods inherited from Plugin

#eql?, #finished, #finished?, #hash, #inspect, lookup, #reload, #running?, #shutdown, #teardown, #terminating?, #to_s

Constructor Details

#initialize(params = {}) ⇒ Base

Returns a new instance of Base.



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/logstash/inputs/base.rb', line 70

def initialize(params={})
  super
  @threadable = false
  config_init(params)
  @tags ||= []

  if @charset && @codec.class.get_config.include?("charset")
    # charset is deprecated on inputs, but provide backwards compatibility
    # by copying the charset setting into the codec.

    @logger.info("Copying input's charset setting into codec", :input => self, :codec => @codec)
    charset = @charset
    @codec.instance_eval { @charset = charset }
  end

  # Backwards compat for the 'format' setting
  case @format
    when "plain"; # do nothing
    when "json"
      @codec = LogStash::Plugin.lookup("codec", "json").new
    when "json_event"
      @codec = LogStash::Plugin.lookup("codec", "oldlogstashjson").new
  end

end

Instance Attribute Details

#paramsObject

Returns the value of attribute params.



66
67
68
# File 'lib/logstash/inputs/base.rb', line 66

def params
  @params
end

#threadableObject

Returns the value of attribute threadable.



67
68
69
# File 'lib/logstash/inputs/base.rb', line 67

def threadable
  @threadable
end

Instance Method Details

#registerObject



97
98
99
# File 'lib/logstash/inputs/base.rb', line 97

def register
  raise "#{self.class}#register must be overidden"
end

#tag(newtag) ⇒ Object



102
103
104
# File 'lib/logstash/inputs/base.rb', line 102

def tag(newtag)
  @tags << newtag
end