Class: LogStash::Plugin
- Inherits:
-
Object
- Object
- LogStash::Plugin
- Defined in:
- lib/logstash/plugin.rb
Direct Known Subclasses
Constant Summary collapse
- NL =
"\n"
Instance Attribute Summary collapse
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#params ⇒ Object
Returns the value of attribute params.
Class Method Summary collapse
Instance Method Summary collapse
- #close ⇒ Object
- #debug_info ⇒ Object
- #do_close ⇒ Object
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(params = nil) ⇒ Plugin
constructor
A new instance of Plugin.
- #inspect ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(params = nil) ⇒ Plugin
Returns a new instance of Plugin.
26 27 28 29 |
# File 'lib/logstash/plugin.rb', line 26 def initialize(params=nil) @params = LogStash::Util.deep_clone(params) @logger = Cabin::Channel.get(LogStash) end |
Instance Attribute Details
#logger ⇒ Object
Returns the value of attribute logger.
10 11 12 |
# File 'lib/logstash/plugin.rb', line 10 def logger @logger end |
#params ⇒ Object
Returns the value of attribute params.
9 10 11 |
# File 'lib/logstash/plugin.rb', line 9 def params @params end |
Class Method Details
.lookup(type, name) ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/logstash/plugin.rb', line 69 def self.lookup(type, name) path = "logstash/#{type}s/#{name}" # first check if plugin already exists in namespace and continue to next step if not begin return namespace_lookup(type, name) rescue NameError logger.debug("Plugin not defined in namespace, checking for plugin file", :type => type, :name => name, :path => path) end # try to load the plugin file. ex.: lookup("filter", "grok") will require logstash/filters/grok require(path) # check again if plugin is now defined in namespace after the require namespace_lookup(type, name) rescue LoadError, NameError => e raise(LogStash::PluginLoadingError, I18n.t("logstash.pipeline.plugin-loading-error", :type => type, :name => name, :path => path, :error => e.to_s)) end |
Instance Method Details
#close ⇒ Object
42 43 44 |
# File 'lib/logstash/plugin.rb', line 42 def close # .. end |
#debug_info ⇒ Object
63 64 65 |
# File 'lib/logstash/plugin.rb', line 63 def debug_info [self.class.to_s, original_params] end |
#do_close ⇒ Object
34 35 36 37 |
# File 'lib/logstash/plugin.rb', line 34 def do_close @logger.debug("closing", :plugin => self) close end |
#eql?(other) ⇒ Boolean
21 22 23 |
# File 'lib/logstash/plugin.rb', line 21 def eql?(other) self.class.name == other.class.name && @params == other.params end |
#hash ⇒ Object
15 16 17 18 |
# File 'lib/logstash/plugin.rb', line 15 def hash params.hash ^ self.class.name.hash end |
#inspect ⇒ Object
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/logstash/plugin.rb', line 51 def inspect if !@params.nil? description = @params .reject { |k, v| v.nil? || (v.respond_to?(:empty?) && v.empty?) } .collect { |k, v| "#{k}=>#{v.inspect}" } return "<#{self.class.name} #{description.join(", ")}>" else return "<#{self.class.name} --->" end end |
#to_s ⇒ Object
46 47 48 |
# File 'lib/logstash/plugin.rb', line 46 def to_s return "#{self.class.name}: #{@params}" end |