loga 2.1.1 → 2.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9ea55004c4f02786aa7326eddf736f2a3f47bdac
4
- data.tar.gz: 79b1ef4aca4cd6ac9aadd3a501cfdc84dca7ca91
3
+ metadata.gz: cdc0f0a6e5b8ea5868e4b85c00638ed67d73fac4
4
+ data.tar.gz: 79969e8d9e8e2a06649e6ad7c5cb857cbce35f86
5
5
  SHA512:
6
- metadata.gz: e9047a4c1a74ddba23a41216915412f5c24bae7e862a2a03b417432cd6619102d939b90217f30dcbf89afcfde06c553698b702f89465173d1bafced72a09f8ae
7
- data.tar.gz: b9b82664a07fc4a4175301734a332bbf8110660d493fd0d5226f9042a908b65181aca610fe05628fc546fa59a92afa52b92ebdb1bec03b08aedcd919caea93a3
6
+ metadata.gz: 3ade6b8ec6ee1c29d66eb45cd2b04ff8d8334a266312fa3ac24268b575b90113ba56d24432aee50f25d41d6a22a1a9903014d518437cdd1c2ccaf9fcf03381aa
7
+ data.tar.gz: 3556ccbed13ad63dad04534a6b87a4b25b5ac75eb84ecba88e059df63aa2e2cf3749a2fb4e3e063fa57494311d2cc01fcb642498e2901099f3352c4151064085
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](http://keepachangelog.com/)
5
5
  and this project adheres to [Semantic Versioning](http://semver.org/).
6
6
 
7
+ ## [2.1.2] - 2016-12-08
8
+ ### Fixed
9
+ - `Loga::Rack::Logger` looks into `env['rack.exception']` for exceptions
10
+
7
11
  ## [2.1.1] - 2016-12-02
8
12
  ### Fixed
9
13
  - Encoding error when converting uploaded file to JSON
@@ -53,6 +57,7 @@ when using simple format. The formatter adds level, timestamp, pid and tags prep
53
57
  ### Changed
54
58
  - Silence ActionDispatch::DebugExceptions' logger
55
59
 
60
+ [2.1.2]: https://github.com/FundingCircle/loga/compare/v2.1.1...v2.1.2
56
61
  [2.1.1]: https://github.com/FundingCircle/loga/compare/v2.1.0...v2.1.1
57
62
  [2.1.0]: https://github.com/FundingCircle/loga/compare/v2.0.0...v2.1.0
58
63
  [2.1.0.pre.1]: https://github.com/FundingCircle/loga/compare/v2.0.0...v2.1.0.pre.1
data/README.md CHANGED
@@ -107,6 +107,8 @@ opposed to a `ActionDispatch::Request`.
107
107
  With Sinatra Loga needs to be configured manually:
108
108
 
109
109
  ```ruby
110
+ # config.ru
111
+ require 'sinatra/base'
110
112
  require 'loga'
111
113
 
112
114
  Loga.configure(
@@ -116,11 +118,19 @@ Loga.configure(
116
118
  tags: [:uuid],
117
119
  )
118
120
 
121
+ class MyApp < Sinatra::Base
122
+ set :logging, false # suppress Sinatra request logger
123
+
124
+ get '/' do
125
+ Loga.logger.info('Everything is Awesome!')
126
+ 'Hello World!'
127
+ end
128
+ end
129
+
119
130
  use Loga::Rack::RequestId
120
131
  use Loga::Rack::Logger
121
132
 
122
- use MyApp
123
- run Sinatra::Application
133
+ run MyApp
124
134
  ```
125
135
 
126
136
  You can now use `Loga.logger` or assign it to your existing logger.
@@ -80,7 +80,8 @@ module Loga
80
80
  end
81
81
 
82
82
  def exception
83
- env['loga.exception'] || env['action_dispatch.exception'] || env['sinatra.error']
83
+ env['loga.exception'] || env['action_dispatch.exception'] ||
84
+ env['sinatra.error'] || env['rack.exception']
84
85
  end
85
86
 
86
87
  def filter_exceptions
@@ -1,3 +1,3 @@
1
1
  module Loga
2
- VERSION = '2.1.1'.freeze
2
+ VERSION = '2.1.2'.freeze
3
3
  end
@@ -1,5 +1,26 @@
1
1
  require 'spec_helper'
2
2
 
3
+ class MySinatraApp < Sinatra::Base
4
+ set :logging, :false
5
+
6
+ get '/ok' do
7
+ 'Hello Sinatra'
8
+ end
9
+
10
+ get '/error' do
11
+ nil.name
12
+ end
13
+
14
+ post '/users' do
15
+ content_type :json
16
+ params.to_json
17
+ end
18
+
19
+ get '/new' do
20
+ redirect '/ok'
21
+ end
22
+ end
23
+
3
24
  RSpec.describe 'Structured logging with Sinatra', timecop: true do
4
25
  let(:io) { StringIO.new }
5
26
  let(:format) {}
@@ -14,41 +35,17 @@ RSpec.describe 'Structured logging with Sinatra', timecop: true do
14
35
  tags: [:uuid, 'TEST_TAG'],
15
36
  )
16
37
  end
38
+
17
39
  let(:last_log_entry) do
18
40
  io.rewind
19
41
  JSON.parse(io.read)
20
42
  end
21
43
 
22
44
  let(:app) do
23
- Class.new(Sinatra::Base) do
24
- # Disable show_exceptions and rely on user defined exception handlers
25
- # (e.i. the error blocks)
26
- set :show_exceptions, false
27
-
45
+ Rack::Builder.new do
28
46
  use Loga::Rack::RequestId
29
47
  use Loga::Rack::Logger
30
-
31
- error do
32
- status 500
33
- body 'Ooops'
34
- end
35
-
36
- get '/ok' do
37
- 'Hello Sinatra'
38
- end
39
-
40
- get '/error' do
41
- nil.name
42
- end
43
-
44
- post '/users' do
45
- content_type :json
46
- params.to_json
47
- end
48
-
49
- get '/new' do
50
- redirect '/ok'
51
- end
48
+ run MySinatraApp
52
49
  end
53
50
  end
54
51
 
@@ -96,6 +96,15 @@ describe Loga::Rack::Logger do
96
96
  include_examples 'logs the event', level: :info
97
97
  end
98
98
 
99
+ context 'when the exception is on rack.exception', focus: true do
100
+ let(:response_status) { 500 }
101
+ let(:exception) { StandardError }
102
+ let(:logged_exception) { exception }
103
+ let(:options) { { 'rack.exception' => exception } }
104
+
105
+ include_examples 'logs the event', level: :error
106
+ end
107
+
99
108
  context 'when no exception is raised' do
100
109
  include_examples 'logs the event', level: :info
101
110
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: loga
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 2.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Funding Circle
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-05 00:00:00.000000000 Z
11
+ date: 2016-12-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport