lib/fluent/engine.rb in fluentd-0.12.20 vs lib/fluent/engine.rb in fluentd-0.12.21

- old
+ new

@@ -12,15 +12,24 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # -module Fluent - require 'fluent/event_router' - require 'fluent/root_agent' - require 'fluent/time' +require 'socket' +require 'msgpack' +require 'cool.io' + +require 'fluent/config' +require 'fluent/event' +require 'fluent/event_router' +require 'fluent/root_agent' +require 'fluent/time' +require 'fluent/system_config' +require 'fluent/plugin' + +module Fluent class EngineClass class DummyMessagePackFactory def packer(*args) MessagePack::Packer.new(*args) end @@ -49,24 +58,27 @@ LOG_EMIT_INTERVAL = 0.1 attr_reader :root_agent attr_reader :matches, :sources attr_reader :msgpack_factory + attr_reader :system_config - def init(opts = {}) + def init(system_config) + @system_config = system_config + BasicSocket.do_not_reverse_lookup = true Plugin.load_plugins if defined?(Encoding) Encoding.default_internal = 'ASCII-8BIT' if Encoding.respond_to?(:default_internal) Encoding.default_external = 'ASCII-8BIT' if Encoding.respond_to?(:default_external) end - suppress_interval(opts[:suppress_interval]) if opts[:suppress_interval] - @suppress_config_dump = opts[:suppress_config_dump] if opts[:suppress_config_dump] - @without_source = opts[:without_source] if opts[:without_source] + suppress_interval(system_config.emit_error_log_interval) unless system_config.emit_error_log_interval.nil? + @suppress_config_dump = system_config.suppress_config_dump unless system_config.suppress_config_dump.nil? + @without_source = system_config.without_source unless system_config.without_source.nil? - @root_agent = RootAgent.new(opts) + @root_agent = RootAgent.new(@system_config) self end def log @@ -162,11 +174,11 @@ events.each {|tag,time,record| begin @event_router.emit(tag, time, record) rescue => e - $log.error "failed to emit fluentd's log event", :tag => tag, :event => record, :error_class => e.class, :error => e + $log.error "failed to emit fluentd's log event", tag: tag, event: record, error_class: e.class, error: e end } end end @@ -191,10 +203,10 @@ @default_loop.stop @default_loop = nil end rescue => e - $log.error "unexpected error", :error_class=>e.class, :error=>e + $log.error "unexpected error", error_class: e.class, error: e $log.error_backtrace ensure $log.info "shutting down fluentd" shutdown if @log_emit_thread