class Fluent::Format::Check

Public Class Methods

new(config_dev, opts = {}) click to toggle source

Initialize

@param [IO|String] config_dev

# 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,
    :use_v1_config => true,
  }
  @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
  @opts[:use_v1_config] = opts[:use_v1_config]
end

Public Instance Methods

run() click to toggle source

Check config file

@raise Fluent::ConfigParseError if conf has syntax errors @raise Fluent::ConfigError if plugin raises config error @return true if success

# File lib/fluent/format/check.rb, line 40
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