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.

Direct Known Subclasses

Threadable

Constant Summary

Constants included from Config::Mixin

Config::Mixin::CONFIGSORT, Config::Mixin::PLUGIN_VERSION_0_9_0, Config::Mixin::PLUGIN_VERSION_1_0_0

Constants inherited from Plugin

Plugin::NL

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.



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

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.



63
64
65
# File 'lib/logstash/inputs/base.rb', line 63

def params
  @params
end

#threadableObject

Returns the value of attribute threadable.



64
65
66
# File 'lib/logstash/inputs/base.rb', line 64

def threadable
  @threadable
end

Instance Method Details

#registerObject



94
95
96
# File 'lib/logstash/inputs/base.rb', line 94

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

#tag(newtag) ⇒ Object



99
100
101
# File 'lib/logstash/inputs/base.rb', line 99

def tag(newtag)
  @tags << newtag
end