low 0.0.13 → 0.0.14

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,12 +7,15 @@ module Low
7
7
  # `Low::ScopedLogger`, with `#level` and `#scope` taken from env.
8
8
  class RequestLogger
9
9
 
10
+ DEFAULT_KEY = 'rack.logger'
11
+
10
12
  def initialize(app, opts = {})
11
13
  @app = app
14
+ @key = opts[:key] || DEFAULT_KEY
12
15
  end
13
16
 
14
17
  def call(env)
15
- env['rack.logger'] = logger(env)
18
+ env[@key] = logger(env)
16
19
  @app.call(env)
17
20
  end
18
21
 
data/lib/low/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Low
2
- VERSION = '0.0.13'
2
+ VERSION = '0.0.14'
3
3
  end
@@ -4,19 +4,27 @@ require 'low/scoped_logger'
4
4
  require 'low/rack/request_logger'
5
5
 
6
6
  describe Low::Rack::RequestLogger do
7
- def test_app
8
- lambda do |env|
9
- [200, {'Content-Type' => 'text/plain'}, env['rack.logger']]
10
- end
11
- end
12
7
 
13
8
  it 'should set rack.logger to an instance of `Low::ScopedLogger` with scope set to \'request_id\'
14
9
  and level set to \'low.log_level\'' do
15
- rack = Low::Rack::RequestLogger.new test_app
10
+ app = lambda do |env|
11
+ [200, {'Content-Type' => 'text/plain'}, env['rack.logger']]
12
+ end
13
+ rack = Low::Rack::RequestLogger.new app
16
14
  response = rack.call({'request_id' => 'abc123', 'low.log_level' => Logger::FATAL})
17
15
  logger = response[2]
18
16
  logger.should be_a(Low::ScopedLogger)
19
17
  logger.scope.should == 'abc123'
20
18
  logger.level.should == Logger::FATAL
21
19
  end
20
+
21
+ it 'should set the specified logger key' do
22
+ app = lambda do |env|
23
+ [200, {'Content-Type' => 'text/plain'}, env['another.logger']]
24
+ end
25
+ rack = Low::Rack::RequestLogger.new app, key: 'another.logger'
26
+ response = rack.call({})
27
+ response[2].should be_a(Low::ScopedLogger)
28
+ end
29
+
22
30
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: low
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 0.0.14
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: