timber 3.0.0 → 3.0.1

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
  SHA256:
3
- metadata.gz: 3a26e7b9b1e27e631deac9a62753d67fabfe532a37446c29ad532fc6948b5682
4
- data.tar.gz: 66c38071146891f8d8e7a763a2486eda7d5aef7fdffbffb9a26dc8128a581e79
3
+ metadata.gz: 3d765ddddb68b5b6af092b021c1e0971bf4979ae93f8c85104c7bddefea7fa30
4
+ data.tar.gz: 156ec4acdf3aa23ffcc87d2b6efaeb260dd5dc191905dbceff76a05eef273adb
5
5
  SHA512:
6
- metadata.gz: 5acf7ca9461dd5b24b20cda20f7f6828e5f78c8fcb8cc44a3ef8a01ec882ba5fbcdec33f522d5753b4ef81a750c27820b33dbfb8d4cdd5eab80a299ce43bdece
7
- data.tar.gz: e47f9313d14194be733203491d82213f87e5d1c2d5f2f6796a29e489dec892b6b699016a657147263e2658fd835f7836b64ed423fa6c882c1dd9171b8e2c51ee
6
+ metadata.gz: a6f2df759bf0545435c7b52c7673871f212a31e00491e90c88ed672380ce344b69c700af3d2757272c6d01b4f722f0ee1c553b9012ac817173a3d5aef5b6dc52
7
+ data.tar.gz: 5bac442f91f99b0a7aaa9f27a6f75ea4a8d197abd68f1860a59f92a220ae817450c9f363ed2b52808602e90180bcf1e13a40ea02dca2b5d58d168b8820b2e6fa
@@ -7,11 +7,19 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [3.0.1] - 2019-04-10
11
+
12
+ ### Fixed
13
+
14
+ - Fixed a bug where `Timber.with_context` was calling a non-existent method. [#205](https://github.com/timberio/timber-ruby/pull/205)
15
+
16
+ ## [3.0.0] - 2019-03-28
17
+
10
18
  ### Changed
11
19
 
12
20
  - Timber's Rails integration has been moved to the optional `timber_rails` gem: https://github.com/timberio/timber-ruby-rails
13
21
  - Timber's Rack integration has been moved to the optional `timber_rack` gem: https://github.com/timberio/timber-ruby-rack
14
- - Custom events are no longer nested under the `custom.event` key, events are now merged into the root docoment.
22
+ - Custom events are no longer nested under the `custom.event` key, events are now merged into the root document.
15
23
  - Custom contexts are no longer nested under the `context.custom` key, contexts are not part of the top-level `context` document.
16
24
  - The Timber JSON schema (`$shema` key) was dropped since the Timber.io service no longer requires a strict schema (structured data in any shape is accepted).
17
25
  - `Timber::LogDevices::HTTP#initialize` now takes a second `source_id` parameter. Timber's new API keys are no longer Timber source specific and therefore require a `source_id` to be specificed. Ex: `Timber::LogDevices::HTTP.new('api_key', 'source_id')`.
@@ -134,7 +142,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
134
142
  instead of applying back pressure.
135
143
 
136
144
 
137
- [Unreleased]: https://github.com/timberio/timber-ruby/compare/v2.6.1...HEAD
145
+ [Unreleased]: https://github.com/timberio/timber-ruby/compare/v3.0.1...HEAD
146
+ [3.0.1]: https://github.com/timberio/timber-ruby/compare/v3.0.0...v3.0.1
147
+ [3.0.0]: https://github.com/timberio/timber-ruby/compare/v2.6.1...v3.0.0
138
148
  [2.6.1]: https://github.com/timberio/timber-ruby/compare/v2.6.0...v2.6.1
139
149
  [2.6.0]: https://github.com/timberio/timber-ruby/compare/v2.5.1...v2.6.0
140
150
  [2.5.1]: https://github.com/timberio/timber-ruby/compare/v2.5.0...v2.5.1
data/README.md CHANGED
@@ -26,7 +26,19 @@ important stats easier than ever.
26
26
 
27
27
  ---
28
28
 
29
- * **[Features](https://docs.timber.io/setup/languages/ruby#features)**
29
+ ### Features
30
+
31
+ * Simple integration. Exposes the same API as the Ruby Logger.
32
+ * Performant, light-weight, and thoughtful design.
33
+ * Support for structured logging.
34
+ * Support for context.
35
+ * Automatic context capturing.
36
+ * Integrates with popular 3rd party libraries, such as Rails and Rack.
37
+
38
+ ---
39
+
40
+ ### Get Started
41
+
30
42
  * **[Installation](https://docs.timber.io/setup/languages/ruby#installation)**
31
43
  * **[Configuration](https://docs.timber.io/setup/languages/ruby#configuration)**
32
44
  * **[Usage](https://docs.timber.io/setup/languages/ruby#usage)**
@@ -0,0 +1,48 @@
1
+ # Upgrading
2
+
3
+ ## 2.x to 3.x
4
+
5
+ ### Overview
6
+
7
+ We're excited to announce the 3.X line of Timber for Ruby! We've been making big
8
+ strides with Timber as a whole and 3.X represents a lot of big improvements:
9
+
10
+ - A lighter code base
11
+ - Better performance
12
+ - A simpler, better install process and strategy
13
+ - New docs: https://docs.timber.io/setup/languages/ruby
14
+ - New integration libraries focused on the specific library they're integrating with
15
+
16
+ - https://github.com/timberio/timber-ruby-rack
17
+ - https://github.com/timberio/timber-ruby-rails
18
+
19
+ Outside of that, 3.0 does not introduce any API changes, and is forward compatbile
20
+ in that regard. This means actions like setting context and logging structured data
21
+ will continue to work as expected.
22
+
23
+ ### Rails
24
+
25
+ If you're on Rails, the upgrade process is simple. Simply add the `timber-rails`
26
+ gem to your `Gemfile`:
27
+
28
+ ```
29
+ gem 'timber-rails', '~> 1.0'
30
+ ```
31
+
32
+ That's it! Everything is taken care of you via a Rails initializer.
33
+
34
+ More info: https://docs.timber.io/setup/languages/ruby/integrations/rack
35
+
36
+ ### Non-rails
37
+
38
+ If you're not on rails, and you're using `Rack`, you'll want to install the
39
+ `timber-rack` gem by adding it to your `Gemfile`:
40
+
41
+ ```
42
+ gem 'timber-rack', '~> 1.0'
43
+ ```
44
+
45
+ That's it! The middleware class names are still the same and should not
46
+ require any altering.
47
+
48
+ More info: https://docs.timber.io/setup/languages/ruby/integrations/rack
@@ -38,6 +38,11 @@ module Timber
38
38
  def reset(*args)
39
39
  instance.reset(*args)
40
40
  end
41
+
42
+ # Convenience method for {CurrentContext#with}. See {CurrentContext#with} for more info.
43
+ def with(*args, &block)
44
+ instance.with(*args, &block)
45
+ end
41
46
  end
42
47
 
43
48
  # Adds contexts but does not remove them. See {#with} for automatic maintenance and {#remove}
@@ -68,6 +73,12 @@ module Timber
68
73
  self
69
74
  end
70
75
 
76
+ def replace(hash)
77
+ @hash = hash
78
+ expire_cache!
79
+ self
80
+ end
81
+
71
82
  # Resets the context to be blank. Use this carefully! This will remove *any* context,
72
83
  # include context that is automatically included with Timber.
73
84
  def reset
@@ -83,6 +94,35 @@ module Timber
83
94
  @snapshot ||= hash.clone
84
95
  end
85
96
 
97
+ # Adds a context and then removes it when the block is finished executing.
98
+ #
99
+ # @note Because context is included with every log line, it is recommended that you limit this
100
+ # to only neccessary data.
101
+ #
102
+ # @example Adding a custom context
103
+ # Timber::CurrentContext.with({build: {version: "1.0.0"}}) do
104
+ # # ... anything logged here will include the context ...
105
+ # end
106
+ #
107
+ # @note Any custom context needs to have a single root key to be valid. i.e. instead of:
108
+ # Timber::CurrentContext.with(job_id: "123", job_name: "Refresh User Account")
109
+ #
110
+ # do
111
+ #
112
+ # Timber::CurrentContext.with(job: {job_id: "123", job_name: "Refresh User Account"})
113
+ #
114
+ # @example Adding multiple contexts
115
+ # Timber::CurrentContext.with(context1, context2) { ... }
116
+ def with(*objects)
117
+ old_hash = hash.clone
118
+ begin
119
+ add(*objects)
120
+ yield
121
+ ensure
122
+ replace(old_hash)
123
+ end
124
+ end
125
+
86
126
  private
87
127
  # The internal hash that is maintained. Use {#with} and {#add} for hash maintenance.
88
128
  def hash
@@ -1,3 +1,3 @@
1
1
  module Timber
2
- VERSION = "3.0.0"
2
+ VERSION = "3.0.1"
3
3
  end
@@ -89,4 +89,25 @@ describe Timber::CurrentContext do
89
89
  expect(described_class.instance.send(:hash)[:build]).to be_nil
90
90
  end
91
91
  end
92
+
93
+ describe ".with" do
94
+ it "should merge the context and cleanup on block exit" do
95
+ expect(described_class.instance.send(:hash)[:build]).to be_nil
96
+
97
+ described_class.with({build: {version: "1.0.0"}}) do
98
+ expect(described_class.instance.send(:hash)[:build]).to eq({:version=>"1.0.0"})
99
+
100
+ described_class.with({testing: {key: "value"}}) do
101
+ expect(described_class.instance.send(:hash)[:build]).to eq({:version=>"1.0.0"})
102
+ expect(described_class.instance.send(:hash)[:testing]).to eq({:key=>"value"})
103
+ end
104
+
105
+ expect(described_class.instance.send(:hash)[:build]).to eq({:version=>"1.0.0"})
106
+ expect(described_class.instance.send(:hash)[:testing]).to be_nil
107
+ end
108
+
109
+ expect(described_class.instance.send(:hash)[:build]).to be_nil
110
+ expect(described_class.instance.send(:hash)[:testing]).to be_nil
111
+ end
112
+ end
92
113
  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: 3.0.0
4
+ version: 3.0.1
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: 2019-03-27 00:00:00.000000000 Z
11
+ date: 2019-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: msgpack
@@ -153,6 +153,7 @@ files:
153
153
  - LICENSE.md
154
154
  - README.md
155
155
  - Rakefile
156
+ - UPGRADING.md
156
157
  - bin/timber
157
158
  - lib/timber.rb
158
159
  - lib/timber/config.rb