class Rack::ActionLogger::Emitter
Public Class Methods
new()
click to toggle source
# File lib/rack/action_logger/emitter.rb, line 4 def initialize @can_emit = !Container.is_emit_started unless @can_emit Rack::ActionLogger.logger.error("#{self.class} is already defined.") Rack::ActionLogger.logger.error("#{Thread.current.backtrace.join("\n")}") end @emit_adapter = Rack::ActionLogger.configuration.emit_adapter @container = Container end
Public Instance Methods
emit(context=nil) { || ... }
click to toggle source
# File lib/rack/action_logger/emitter.rb, line 14 def emit(context=nil) @container.is_emit_started = true @container.import(context) if context result = yield emit_all_logs # emit log unless exception raised result ensure @container.clear if @can_emit end
Private Instance Methods
emit_all_logs()
click to toggle source
# File lib/rack/action_logger/emitter.rb, line 26 def emit_all_logs return unless @can_emit emit_request_log emit_append_logs end
emit_append_logs()
click to toggle source
# File lib/rack/action_logger/emitter.rb, line 39 def emit_append_logs @container.append_logs.each do |hash| hash = format_tag(hash) @emit_adapter.emit(@container.attributes.merge(hash)) end end
emit_request_log()
click to toggle source
# File lib/rack/action_logger/emitter.rb, line 32 def emit_request_log return unless (@container.request_log.is_a?(Hash) && @container.request_log != {}) hash = @container.request_log.merge @container.attributes hash = format_tag(hash) @emit_adapter.emit(hash) end
format_tag(hash)
click to toggle source
# File lib/rack/action_logger/emitter.rb, line 46 def format_tag(hash) if hash[:tag] hash[:tag] = [Rack::ActionLogger.configuration.tag_prefix, hash[:tag]].join('.') else hash[:tag] = Rack::ActionLogger.configuration.default_tag end hash end