Sha256: f894ceef64bdd15c6e187bd612c46d7139b05a063d16a030ae7ffeb45fd2ed7e
Contents?: true
Size: 1.29 KB
Versions: 2
Compression:
Stored size: 1.29 KB
Contents
Rails::Rack::Logger # Replace rack started message with a semantic equivalent module Rails module Rack class Logger mattr_accessor :named_tags @logger = SemanticLogger['Rack'] def self.logger @logger end def call(env) request = ActionDispatch::Request.new(env) proc = -> { call_app(request, env) } proc = -> { logger.tagged(compute_tags(request), &proc) } if @taggers && !@taggers.empty? named_tags ? SemanticLogger.named_tagged(compute_named_tags(request), &proc) : proc.call end def started_request_message(request) { message: 'Started', payload: { method: request.request_method, path: request.filtered_path, ip: request.ip } } end private def logger self.class.logger end def compute_named_tags(request) # :doc: tagged = {} named_tags.each_pair do |tag, value| resolved = case value when Proc value.call(request) when Symbol request.send(value) else value end tagged[tag] = resolved unless resolved.nil? end tagged end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rails_semantic_logger-4.1.1 | lib/rails_semantic_logger/extensions/rails/rack/logger.rb |
rails_semantic_logger-4.1.0 | lib/rails_semantic_logger/extensions/rails/rack/logger.rb |