pliny 0.24.0 → 0.25.0

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: 6b59272bbe834eaf737b9ffe3e4769e54f8897cf
4
- data.tar.gz: 13bfa08975ac6f65c74a686e54cf22608bbab639
3
+ metadata.gz: fc58fa1c7528a90b019d6f7d01dcb733909c918d
4
+ data.tar.gz: ed596145f95be0ff622f9cdcf2e6a5448a96a56e
5
5
  SHA512:
6
- metadata.gz: 1d76b1d6abaf678044111133e3fcb4aa587b88e87c866d8e60adbc03543e77f6e1cb959609eea9b8bb75931ea6f206c49c8447852b4035ca00a6360bd4408e0c
7
- data.tar.gz: 8a4e54331f8642b58176358fb3d57845cf623dc93a3d8e0bdd301ea853a84ee29db9c2d1dc5567b6db6cf3fc5f920d8348b419a09f0b3a4ae49593597110b4d6
6
+ metadata.gz: 300c529e268a5e168dd015a42d3a1a68b3fceaf6359c47ca8288aa6e08cfcf222f029a0cb0f6541c160ad000951ebb607144c4191eecaa981b75fbbe75cd2679
7
+ data.tar.gz: ad0e7f83fdd78ccd9c97c2fcdf296b17c842874cf9e372e592a666072b0361cf9a1e4a1aebdda921130115b5420e03623ea472ebcb24946ffafd4ed17a9c33d8
@@ -18,7 +18,7 @@ module Pliny
18
18
  private
19
19
 
20
20
  def fetch_scope(context:, rack_env:)
21
- scope = {}
21
+ scope = { custom: context }
22
22
  unless rack_env.empty?
23
23
  scope[:request] = proc { extract_request_data_from_rack(rack_env) }
24
24
  end
data/lib/pliny/log.rb CHANGED
@@ -4,6 +4,10 @@ module Pliny
4
4
  log_to_stream(stdout || $stdout, merge_log_contexts(data), &block)
5
5
  end
6
6
 
7
+ def log_with_default_context(data, &block)
8
+ log_to_stream(stdout || $stdout, default_context.merge(data), &block)
9
+ end
10
+
7
11
  def log_without_context(data, &block)
8
12
  log_to_stream(stdout || $stdout, data, &block)
9
13
  end
data/lib/pliny/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Pliny
2
- VERSION = "0.24.0"
2
+ VERSION = "0.25.0"
3
3
  end
@@ -1 +1 @@
1
- 2.3.3
1
+ 2.4.0
data/lib/template/Gemfile CHANGED
@@ -1,10 +1,10 @@
1
1
  source "https://rubygems.org"
2
- ruby "2.3.3"
2
+ ruby "2.4.0"
3
3
 
4
4
  gem "multi_json"
5
5
  gem "oj"
6
6
  gem "pg"
7
- gem "pliny", "~> 0.24"
7
+ gem "pliny", "~> 0.25"
8
8
  gem "pry"
9
9
  gem "puma", "~> 3"
10
10
  gem "rack-ssl"
@@ -6,7 +6,7 @@ Routes = Rack::Builder.new do
6
6
  use Pliny::Middleware::Metrics
7
7
  use Pliny::Middleware::CanonicalLogLine,
8
8
  emitter: -> (data) {
9
- Pliny.log_without_context({ canonical_log_line: true }.merge(data))
9
+ Pliny.log_with_default_context({ canonical_log_line: true }.merge(data))
10
10
  }
11
11
  use Pliny::Middleware::RescueErrors, raise: Config.raise_errors?
12
12
  if Config.timeout.positive?
@@ -7,7 +7,7 @@ describe Pliny::ErrorReporters::Rollbar do
7
7
 
8
8
  describe "#notify" do
9
9
  let(:exception) { StandardError.new("Something went wrong") }
10
- let(:context) { {} }
10
+ let(:context) { { step: :foo } }
11
11
  let(:rack_env) { { "rack.input" => StringIO.new } }
12
12
 
13
13
  subject(:notify) do
@@ -28,7 +28,8 @@ describe Pliny::ErrorReporters::Rollbar do
28
28
  it "scopes the rollbar notification" do
29
29
  notify
30
30
  expect(::Rollbar).to have_received(:scoped).once.with(hash_including(
31
- request: instance_of(Proc)
31
+ request: instance_of(Proc),
32
+ custom: { step: :foo }
32
33
  ))
33
34
  end
34
35
 
@@ -45,9 +46,9 @@ describe Pliny::ErrorReporters::Rollbar do
45
46
  assert_kind_of(Hash, rack_env)
46
47
  end
47
48
 
48
- it "reports to Rollbar with an empty scope" do
49
+ it "reports to Rollbar without request data in the scope" do
49
50
  notify
50
- expect(Rollbar).to have_received(:scoped).once.with({})
51
+ expect(Rollbar).to have_received(:scoped).once.with({ custom: {step: :foo} })
51
52
  end
52
53
 
53
54
  it "delegates to #report_exception_to_rollbar" do
data/spec/log_spec.rb CHANGED
@@ -38,6 +38,13 @@ describe Pliny::Log do
38
38
  Pliny.log(foo: "bar")
39
39
  end
40
40
 
41
+ it "logs with just default context" do
42
+ Pliny.default_context = { app: "pliny" }
43
+ Pliny::RequestStore.store[:log_context] = { request_store: true }
44
+ expect(@io).to receive(:print).with("app=pliny foo=bar\n")
45
+ Pliny.log_with_default_context(foo: "bar")
46
+ end
47
+
41
48
  it "logs without context" do
42
49
  Pliny.default_context = { app: "pliny" }
43
50
  expect(@io).to receive(:print).with("foo=bar\n")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pliny
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.24.0
4
+ version: 0.25.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandur Leach
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-02-16 00:00:00.000000000 Z
12
+ date: 2017-03-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport