class Fluent::SystemConfig

Constants

SYSTEM_CONFIG_PARAMETERS

Public Class Methods

blank_system_config() click to toggle source
# File lib/fluent/system_config.rb, line 114
def self.blank_system_config
  Fluent::Config::Element.new('<SYSTEM>', '', {}, [])
end
create(conf, strict_config_value=false) click to toggle source
# File lib/fluent/system_config.rb, line 106
def self.create(conf, strict_config_value=false)
  systems = conf.elements(name: 'system')
  return SystemConfig.new if systems.empty?
  raise Fluent::ConfigError, "<system> is duplicated. <system> should be only one" if systems.size > 1

  SystemConfig.new(systems.first, strict_config_value)
end
new(conf=nil, strict_config_value=false) click to toggle source
Calls superclass method Fluent::Configurable::new
# File lib/fluent/system_config.rb, line 128
def initialize(conf=nil, strict_config_value=false)
  super()
  conf ||= SystemConfig.blank_system_config
  configure(conf, strict_config_value)
end
overwrite_system_config(hash) { || ... } click to toggle source
# File lib/fluent/system_config.rb, line 118
def self.overwrite_system_config(hash)
  older = defined?($_system_config) ? $_system_config : nil
  begin
    $_system_config = SystemConfig.new(Fluent::Config::Element.new('system', '', hash, []))
    yield
  ensure
    $_system_config = older
  end
end

Public Instance Methods

configure(conf, strict_config_value=false) click to toggle source
Calls superclass method Fluent::Configurable#configure
# File lib/fluent/system_config.rb, line 134
def configure(conf, strict_config_value=false)
  strict = strict_config_value
  if !strict && conf && conf.has_key?("strict_config_value")
    strict = Fluent::Config.bool_value(conf["strict_config_value"])
  end

  begin
    super(conf, strict)
  rescue ConfigError => e
    $log.error "config error in:\n#{conf}"
    $log.error 'config error', error: e
    $log.debug_backtrace
    exit!(1)
  end

  @log_level = Log.str_to_level(@log_level.to_s) if @log_level
end
dup() click to toggle source
# File lib/fluent/system_config.rb, line 152
def dup
  s = SystemConfig.new
  SYSTEM_CONFIG_PARAMETERS.each do |param|
    s.__send__("#{param}=", instance_variable_get("@#{param}"))
  end
  s
end
overwrite_variables(**opt) click to toggle source
# File lib/fluent/system_config.rb, line 160
def overwrite_variables(**opt)
  SYSTEM_CONFIG_PARAMETERS.each do |param|
    if opt.key?(param) && !opt[param].nil? && instance_variable_defined?("@#{param}")
      instance_variable_set("@#{param}", opt[param])
    end
  end
end