Class: RailsSemanticLogger::Rack::Logger

Inherits:
ActiveSupport::LogSubscriber
  • Object
show all
Defined in:
lib/rails_semantic_logger/rack/logger.rb

Class Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app, taggers = nil) ⇒ Logger

Returns a new instance of Logger.



15
16
17
18
# File 'lib/rails_semantic_logger/rack/logger.rb', line 15

def initialize(app, taggers = nil)
  @app     = app
  @taggers = taggers || []
end

Class Attribute Details

.loggerObject (readonly)

Returns the value of attribute logger.



11
12
13
# File 'lib/rails_semantic_logger/rack/logger.rb', line 11

def logger
  @logger
end

.started_request_log_levelObject

Returns the value of attribute started_request_log_level.



12
13
14
# File 'lib/rails_semantic_logger/rack/logger.rb', line 12

def started_request_log_level
  @started_request_log_level
end

Instance Method Details

#call(env) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/rails_semantic_logger/rack/logger.rb', line 20

def call(env)
  request = ActionDispatch::Request.new(env)

  # Check for named tags (Hash)
  if @taggers && !@taggers.empty?
    tags = @taggers.is_a?(Hash) ? compute_named_tags(request) : compute_tags(request)
    logger.tagged(tags) { call_app(request, env) }
  else
    call_app(request, env)
  end
end