Class: LogStash::Config::Source::Local::ConfigStringLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/logstash/config/source/local.rb

Constant Summary collapse

INPUT_BLOCK_RE =
/input *{/
OUTPUT_BLOCK_RE =
/output *{/
EMPTY_RE =
/^\s*$/

Class Method Summary collapse

Class Method Details

.read(config_string) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/logstash/config/source/local.rb', line 23

def self.read(config_string)
  config_parts = [org.logstash.common.SourceWithMetadata.new("string", "config_string", 0, 0, config_string)]

  # Make sure we have an input and at least 1 output
  # if its not the case we will add stdin and stdout
  # this is for backward compatibility reason
  if !INPUT_BLOCK_RE.match(config_string)
    config_parts << org.logstash.common.SourceWithMetadata.new(self.class.name, "default input", 0, 0, LogStash::Config::Defaults.input)

  end

  # include a default stdout output if no outputs given
  if !OUTPUT_BLOCK_RE.match(config_string)
    config_parts << org.logstash.common.SourceWithMetadata.new(self.class.name, "default output", 0, 0, LogStash::Config::Defaults.output)
  end

  config_parts
end