Class: LogStash::Config::File

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/logstash/config/file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text) ⇒ File

Returns a new instance of File.



14
15
16
17
18
# File 'lib/logstash/config/file.rb', line 14

def initialize(text)
  @logger = Cabin::Channel.get(LogStash)
  @text = text
  @config = parse(text)
end

Instance Attribute Details

#loggerObject

Returns the value of attribute logger.



11
12
13
# File 'lib/logstash/config/file.rb', line 11

def logger
  @logger
end

Instance Method Details

#eachObject



34
35
36
# File 'lib/logstash/config/file.rb', line 34

def each
  @config.recursive_select(LogStash::Config::AST::Plugin)
end

#parse(text) ⇒ Object

def initialize



20
21
22
23
24
25
26
27
# File 'lib/logstash/config/file.rb', line 20

def parse(text)
  grammar = LogStashConfigParser.new
  result = grammar.parse(text)
  if result.nil?
    raise LogStash::ConfigurationError, grammar.failure_reason
  end
  return result
end

#plugin(plugin_type, name, *args) ⇒ Object

def parse



29
30
31
32
# File 'lib/logstash/config/file.rb', line 29

def plugin(plugin_type, name, *args)
  klass = LogStash::Plugin.lookup(plugin_type, name)
  return klass.new(*args)
end