Class: Fluent::SystemConfig
- Inherits:
-
Object
- Object
- Fluent::SystemConfig
show all
- Includes:
- Configurable
- Defined in:
- lib/fluent/system_config.rb
Defined Under Namespace
Modules: Mixin
Constant Summary
collapse
- SYSTEM_CONFIG_PARAMETERS =
[
:workers, :root_dir, :log_level,
:suppress_repeated_stacktrace, :emit_error_log_interval, :suppress_config_dump,
:log_event_verbose,
:without_source, :rpc_endpoint, :enable_get_dump, :process_name,
:file_permission, :dir_permission,
]
Configurable::CONFIG_TYPE_REGISTRY
Class Method Summary
collapse
Instance Method Summary
collapse
#config, #configure_proxy_generate, #configured_section_create, included, lookup_type, register_type
Constructor Details
#initialize(conf = nil) ⇒ SystemConfig
Returns a new instance of SystemConfig.
76
77
78
79
80
|
# File 'lib/fluent/system_config.rb', line 76
def initialize(conf=nil)
super()
conf ||= SystemConfig.blank_system_config
configure(conf)
end
|
Class Method Details
.blank_system_config ⇒ Object
62
63
64
|
# File 'lib/fluent/system_config.rb', line 62
def self.blank_system_config
Fluent::Config::Element.new('<SYSTEM>', '', {}, [])
end
|
.create(conf) ⇒ Object
54
55
56
57
58
59
60
|
# File 'lib/fluent/system_config.rb', line 54
def self.create(conf)
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)
end
|
.overwrite_system_config(hash) ⇒ Object
66
67
68
69
70
71
72
73
74
|
# File 'lib/fluent/system_config.rb', line 66
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
|
Instance Method Details
#apply(supervisor) ⇒ Object
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
# File 'lib/fluent/system_config.rb', line 123
def apply(supervisor)
system = self
supervisor.instance_eval {
SYSTEM_CONFIG_PARAMETERS.each do |param|
param_value = system.__send__(param)
next if param_value.nil?
case param
when :log_level
@log.level = @log_level = param_value
when :emit_error_log_interval
@suppress_interval = param_value
else
instance_variable_set("@#{param}", param_value)
end
end
}
end
|
#attach(supervisor) ⇒ Object
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
# File 'lib/fluent/system_config.rb', line 96
def attach(supervisor)
system = self
supervisor.instance_eval {
SYSTEM_CONFIG_PARAMETERS.each do |param|
case param
when :rpc_endpoint, :enable_get_dump, :process_name, :file_permission, :dir_permission
next when :emit_error_log_interval
system.emit_error_log_interval = @suppress_interval if @suppress_interval
when :log_level
ll_value = instance_variable_get("@log_level")
if ll_value != Fluent::Log::LEVEL_INFO
system.log_level = ll_value
end
else
next unless instance_variable_defined?("@#{param}")
supervisor_value = instance_variable_get("@#{param}")
next if supervisor_value.nil?
system.send("#{param}=", supervisor_value)
end
end
}
end
|
82
83
84
85
86
|
# File 'lib/fluent/system_config.rb', line 82
def configure(conf)
super
@log_level = Log.str_to_level(@log_level.to_s) if @log_level
end
|
#dup ⇒ Object
88
89
90
91
92
93
94
|
# File 'lib/fluent/system_config.rb', line 88
def dup
s = SystemConfig.new
SYSTEM_CONFIG_PARAMETERS.each do |param|
s.__send__("#{param}=", instance_variable_get("@#{param}"))
end
s
end
|