Sha256: 712b7cd920a901ade3a259b30f87018ab8e8dcd06ed8509e1dc49249c1536ab6
Contents?: true
Size: 725 Bytes
Versions: 2
Compression:
Stored size: 725 Bytes
Contents
require 'logger' require 'low/scoped_logger' module Low module Rack # `RequestLogger` sets 'rack.logger' to an instance of # `Low::ScopedLogger`, with `#level` and `#scope` taken from env. class RequestLogger DEFAULT_KEY = 'rack.logger' def initialize(app, opts = {}) @app = app @key = opts[:key] || DEFAULT_KEY end def call(env) env[@key] = logger(env) @app.call(env) end def logger(env) logger = Low::ScopedLogger.new(env['rack.errors']) if level = env['low.log_level'] || env['log_level'] logger.level = level end logger.scope = env['request_id'] logger end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
low-0.0.16 | lib/low/rack/request_logger.rb |
low-0.0.15 | lib/low/rack/request_logger.rb |