Class: Fluent::Format::Check

Inherits:
Object
  • Object
show all
Defined in:
lib/fluent/format/check.rb

Instance Method Summary collapse

Constructor Details

#initialize(config_dev, opts = {}) ⇒ Check

Initialize

Parameters:

  • config_dev (IO|String)


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/fluent/format/check.rb', line 9

def initialize(config_dev, opts = {})
  @opts = {
    :config_path => config_dev, # Fluent::DEFAULT_CONFIG_PATH,
    :plugin_dirs => [Fluent::DEFAULT_PLUGIN_DIR],
    :log_level => Fluent::Log::LEVEL_INFO,
    :log_path => nil,
    :daemonize => false,
    :libs => [],
    :setup_path => nil,
    :chuser => nil,
    :chgroup => nil,
    :suppress_interval => 0,
    :suppress_repeated_stacktrace => false,
  }
  @opts[:plugin_dirs] += opts[:plugin_dirs] if opts[:plugin_dirs] and !opts[:plugin_dirs].empty?
  @opts[:libs] += opts[:libs] if opts[:libs] and !opts[:libs].empty?
  @opts[:inline_config] = opts[:inline_config]
  @opts[:gemfile] = opts[:gemfile]
  @opts[:gem_install_path] = opts[:gem_install_path]
  if config_dev.respond_to?(:read) # IO object
    @opts[:config_path] = Tempfile.open('fluent-format') {|f| f.puts(config_dev.read); f.path }
  end
end

Instance Method Details

#runObject

Check config file

Returns:

  • true if success

Raises:

  • Fluent::ConfigParseError if conf has syntax errors

  • Fluent::ConfigError if plugin raises config error



38
39
40
41
42
43
44
45
46
# File 'lib/fluent/format/check.rb', line 38

def run
  if @opts[:config_path].respond_to?(:read) # IO object
    @opts[:config_path] = Tempfile.open('fluent-format') {|fp|
      fp.puts(@opts[:config_path].read); fp.path
    }
  end
  Fluent::Format::BundlerInjection.new(@opts).run
  Fluent::Supervisor.new(@opts).extended_dry_run
end