timber 2.6.0.pre.beta1 → 2.6.0.pre.beta2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 10838667c7f285fea9c51270f12594b2106299e1
4
- data.tar.gz: f91eaaac75c0ed243686771c415a3f44d6c431b3
3
+ metadata.gz: 52dde0fadd6632da69428d41199325ddebf0e6a4
4
+ data.tar.gz: 4f313fdc346a21c1a5ad34ceb384068bab70a6d1
5
5
  SHA512:
6
- metadata.gz: 8cc093229929a57566e15f4fe81a9f2fbf36c0259a85123e43cbe077e9a14828147620b60be1a7953560ac691923146dcccb2075adbe64fb331bae9a1e388206
7
- data.tar.gz: 5478c747ded3aa62d3fcf0b877e5e09bccafb94c72e1b4812b2dea0cac2aa5fe2e86435532c66f16b35596178c64d2502a40687fe97437f13e6db641cbb296b8
6
+ metadata.gz: c851eb624acd150eb033bbcdc31685916112ba8d0e69816955d6b66b056cb0aadba55231519299ce409ca487c33e01f6fa0168a7c982734c95c1434830280a4c
7
+ data.tar.gz: 20143122643afb851984e7b44cf3f52a6cdf300b8a15e21df332c83f0e1dcd6bbd6881c2acb01dedf3e59dde85b604c2d03a6eb075a921aeccb7c269278baa0a
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [2.6.0-beta2] - 2017-11-16
11
+
12
+ ### Fixed
13
+
14
+ - Fixes an issue where a reference to the current custom context map was being capture during log line creation and then later self-modifying to make the context invalid.
15
+
10
16
  ## [2.6.0-beta1] - 2017-10-28
11
17
 
12
18
  ### Fixed
@@ -14,6 +20,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
14
20
  - Encoding and rewind issues for file upload parameters have been resolved. Timber
15
21
  improved attribute normalization across all contexts and events, ignoring binary
16
22
  values like this in general.
23
+ - Fixes `::ActionDispatch::ExceptionWrapper` version detection preventing the `undefined method clean for #<Hash:->` error when an exception is raised in a Rack request.
17
24
 
18
25
  ## [2.5.1] - 2017-10-27
19
26
 
@@ -111,7 +118,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
111
118
  instead of applying back pressure.
112
119
 
113
120
 
114
- [Unreleased]: https://github.com/timberio/timber-ruby/compare/v2.6.0-beta1...HEAD
121
+ [Unreleased]: https://github.com/timberio/timber-ruby/compare/v2.6.0-beta2...HEAD
122
+ [2.6.0-beta2]: https://github.com/timberio/timber-ruby/compare/v2.6.0-beta1...v2.6.0-beta2
115
123
  [2.6.0-beta1]: https://github.com/timberio/timber-ruby/compare/v2.5.1...v2.6.0-beta1
116
124
  [2.5.1]: https://github.com/timberio/timber-ruby/compare/v2.5.0...v2.5.1
117
125
  [2.5.0]: https://github.com/timberio/timber-ruby/compare/v2.4.0...v2.5.0
@@ -120,7 +120,13 @@ module Timber
120
120
  # since the context can change as execution proceeds. Note that individual contexts
121
121
  # should be immutable, and we implement snapshot caching as a result of this assumption.
122
122
  def snapshot
123
- @snapshot ||= hash.clone
123
+ @snapshot ||= begin
124
+ snapshot = hash.clone
125
+ if snapshot.key?(:custom)
126
+ snapshot[:custom] = hash[:custom].clone
127
+ end
128
+ snapshot
129
+ end
124
130
  end
125
131
 
126
132
  private
@@ -16,7 +16,7 @@ module Timber
16
16
  def initialize(attributes)
17
17
  normalizer = Util::AttributeNormalizer.new(attributes)
18
18
  @name = normalizer.fetch!(:name, :string)
19
- @error_message = normalizer.fetch!(:error_message, :string, :limit => MESSAGE_MAX_BYTES)
19
+ @error_message = normalizer.fetch(:error_message, :string, :limit => MESSAGE_MAX_BYTES)
20
20
  @backtrace = normalizer.fetch(:backtrace, :array)
21
21
  end
22
22
 
@@ -35,7 +35,13 @@ module Timber
35
35
  end
36
36
 
37
37
  def message
38
- "#{name} (#{error_message})"
38
+ message = "#{name}"
39
+
40
+ if !error_message.nil?
41
+ message << " (#{error_message})"
42
+ end
43
+
44
+ message
39
45
  end
40
46
  end
41
47
  end
@@ -18,11 +18,8 @@ module Timber
18
18
  # {Timber::Events::Error}.
19
19
  class ErrorEvent < Middleware
20
20
  # We determine this when the app loads to avoid the overhead on a per request basis.
21
- EXCEPTION_WRAPPER_TAKES_CLEANER = if Gem.loaded_specs["rails"]
22
- Gem.loaded_specs["rails"].version >= Gem::Version.new('5.0.0')
23
- else
24
- false
25
- end
21
+ EXCEPTION_WRAPPER_TAKES_CLEANER = defined?(::ActionDispatch::ExceptionWrapper) &&
22
+ !::ActionDispatch::ExceptionWrapper.instance_methods.include?(:env)
26
23
 
27
24
  def call(env)
28
25
  begin
@@ -147,6 +147,7 @@ module Timber
147
147
  req['Authorization'] = authorization_payload
148
148
  req['Content-Type'] = CONTENT_TYPE
149
149
  req['User-Agent'] = USER_AGENT
150
+
150
151
  req.body = msgs.to_msgpack
151
152
  req
152
153
  end
@@ -14,7 +14,6 @@ module Timber
14
14
  def fetch!(key, type, options = {})
15
15
  v = fetch(key, type, options)
16
16
  if v.nil?
17
- raise @attributes.inspect
18
17
  raise ArgumentError.new("The #{key.inspect} attribute is required")
19
18
  end
20
19
  v
@@ -1,3 +1,3 @@
1
1
  module Timber
2
- VERSION = "2.6.0-beta1"
2
+ VERSION = "2.6.0-beta2"
3
3
  end
@@ -98,6 +98,18 @@ describe Timber::CurrentContext, :rails_23 => true do
98
98
  end
99
99
  end
100
100
 
101
+ describe ".snapshot" do
102
+ it "shoud properly snapshot custom contexts" do
103
+ snapshot = nil
104
+
105
+ described_class.with({build: {version: "1.0.0"}}) do
106
+ snapshot = described_class.instance.snapshot
107
+ end
108
+
109
+ expect(snapshot[:custom]).to eq({:build=>{:version=>"1.0.0"}})
110
+ end
111
+ end
112
+
101
113
  describe ".with" do
102
114
  it "should merge the context and cleanup on block exit" do
103
115
  expect(described_class.instance.send(:hash)[:custom]).to be_nil
@@ -0,0 +1,63 @@
1
+ require "spec_helper"
2
+
3
+ if defined?(::Rack)
4
+ describe Timber::Integrations::Rack::ErrorEvent do
5
+ let(:time) { Time.utc(2016, 9, 1, 12, 0, 0) }
6
+ let(:io) { StringIO.new }
7
+ let(:logger) do
8
+ logger = Timber::Logger.new(io)
9
+ logger.level = ::Logger::INFO
10
+ logger
11
+ end
12
+
13
+ around(:each) do |example|
14
+ class RackErrorController < ActionController::Base
15
+ layout nil
16
+
17
+ hook_name = respond_to?(:before_action) ? "before_action" : "before_filter"
18
+ send(hook_name) do
19
+ raise "Boom!"
20
+ end
21
+
22
+ def index
23
+ Thread.current[:_timber_context_snapshot] = Timber::CurrentContext.instance.snapshot
24
+ render json: {}
25
+ end
26
+
27
+ def method_for_action(action_name)
28
+ action_name
29
+ end
30
+ end
31
+
32
+ ::RailsApp.routes.draw do
33
+ get '/rack_error' => 'rack_error#index'
34
+ end
35
+
36
+ with_rails_logger(logger) do
37
+ Timecop.freeze(time) { example.run }
38
+ end
39
+
40
+ Object.send(:remove_const, :RackErrorController)
41
+ end
42
+
43
+ describe "#process" do
44
+ it "should log the exception" do
45
+ allow(Benchmark).to receive(:ms).and_return(1).and_yield
46
+
47
+ expect { dispatch_rails_request("/rack_error") }.to raise_error(RuntimeError)
48
+
49
+ lines = clean_lines(io.string.split("\n"))
50
+ expect(lines.length).to eq(3)
51
+
52
+ expect(lines[0]).to start_with("Started GET \"/rack_error\" @metadata ")
53
+ expect(lines[1]).to start_with("Processing by RackErrorController#index as HTML @metadata ")
54
+ expect(lines[2]).to start_with("RuntimeError (Boom!) @metadata")
55
+ end
56
+ end
57
+
58
+ # Remove blank lines since Rails does this to space out requests in the logs
59
+ def clean_lines(lines)
60
+ lines.select { |line| !line.start_with?(" @metadat") }
61
+ end
62
+ end
63
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: timber
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.0.pre.beta1
4
+ version: 2.6.0.pre.beta2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Timber Technologies, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-28 00:00:00.000000000 Z
11
+ date: 2017-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: msgpack
@@ -284,6 +284,7 @@ files:
284
284
  - spec/timber/integrations/action_dispatch/debug_exceptions_spec.rb
285
285
  - spec/timber/integrations/action_view/log_subscriber_spec.rb
286
286
  - spec/timber/integrations/active_record/log_subscriber_spec.rb
287
+ - spec/timber/integrations/rack/error_event_spec.rb
287
288
  - spec/timber/integrations/rack/http_context_spec.rb
288
289
  - spec/timber/integrations/rack/http_events_spec.rb
289
290
  - spec/timber/integrations/rack/session_context_spec.rb
@@ -354,6 +355,7 @@ test_files:
354
355
  - spec/timber/integrations/action_dispatch/debug_exceptions_spec.rb
355
356
  - spec/timber/integrations/action_view/log_subscriber_spec.rb
356
357
  - spec/timber/integrations/active_record/log_subscriber_spec.rb
358
+ - spec/timber/integrations/rack/error_event_spec.rb
357
359
  - spec/timber/integrations/rack/http_context_spec.rb
358
360
  - spec/timber/integrations/rack/http_events_spec.rb
359
361
  - spec/timber/integrations/rack/session_context_spec.rb