timber 2.2.3 → 2.3.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: ef7182ad5bb03fc0f9a971879ae012c10520f359
4
- data.tar.gz: 384aa8c04255fb098c6611e36ab30e9684dbcc75
3
+ metadata.gz: ee78c33713b07a95e67fced3d964c9382ff1253d
4
+ data.tar.gz: cbcee8bd46fe73f4f2dfaf6f69562264609d7ec3
5
5
  SHA512:
6
- metadata.gz: 06b4a003bf003e06c6a775e48d573571ded4604daff22a120d00ed8ee3eec1f5a8dcdb7747648a1df48b6ff99a863e0287a89e7a1ffadf29bbc0a11813f94f0b
7
- data.tar.gz: 8bfdbdc650516fd1aa24ba9c6c8955f849167a7fd4a8291f03929e1bac437b48f691bde7c3c8fd49a61b8911947ae2e4934540634bbb1d3404d153ade9f630a9
6
+ metadata.gz: d7a4583f3ca1a1bb634e45f2cbfc0d460e09daff20302226fe9465c9162efc471e6161eec6687f584741f7c4a84943f71076c598e2720b3b049d7975e8711712
7
+ data.tar.gz: 5b4fa450266005578ed20647067ee6694e5e6a1b79fd07c004a3e863e736072f92b7e9fa4a9feb660f4bfaf4b1fea8faa01ccc0ca2fccf68637658142ad0c697
@@ -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.3.0] - 2017-09-26
11
+
12
+ ### Added
13
+
14
+ - Added the ability to pass additional loggers when instantiating a `::Timber::Logger`.
15
+
10
16
  ## [2.2.3] - 2017-09-18
11
17
 
12
18
  ### Fixed
@@ -40,7 +46,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
40
46
  instead of applying back pressure.
41
47
 
42
48
 
43
- [Unreleased]: https://github.com/timberio/timber-ruby/compare/v2.2.3...HEAD
49
+ [Unreleased]: https://github.com/timberio/timber-ruby/compare/v2.3.0...HEAD
50
+ [2.3.0]: https://github.com/timberio/timber-ruby/compare/v2.2.2...v2.3.0
44
51
  [2.2.2]: https://github.com/timberio/timber-ruby/compare/v2.2.2...v2.2.3
45
52
  [2.2.2]: https://github.com/timberio/timber-ruby/compare/v2.2.1...v2.2.2
46
53
  [2.2.1]: https://github.com/timberio/timber-ruby/compare/v2.2.0...v2.2.1
data/README.md CHANGED
@@ -24,7 +24,7 @@ you more productive.
24
24
  1. In your `Gemfile`, add the `timber` gem:
25
25
 
26
26
  ```ruby
27
- gem 'timber', '~> 2.1'
27
+ gem 'timber', '~> 2.3'
28
28
  ```
29
29
 
30
30
  2. In your `shell`, run:
@@ -157,16 +157,23 @@ module Timber
157
157
  #
158
158
  # @example Logging to a file and the Timber HTTP device (multiple log devices)
159
159
  # http_device = Timber::LogDevices::HTTP.new("my-timber-api-key")
160
- # file_device = Logger::LogDevice.new("path/to/file.log")
161
- # logger = Timber::Logger.new(http_device, file_device)
162
- def initialize(*io_devices)
163
- if io_devices.size == 0
164
- raise ArgumentError.new("At least one IO device must be provided when instantiating " +
165
- "a Timber::Logger. Ex: Timber::Logger.new(STDOUT).")
160
+ # file_logger = ::Logger.new("path/to/file.log")
161
+ # logger = Timber::Logger.new(http_device, file_logger)
162
+ def initialize(*io_devices_and_loggers)
163
+ if io_devices_and_loggers.size == 0
164
+ raise ArgumentError.new("At least one IO device or Logger must be provided when " +
165
+ "instantiating a Timber::Logger. Ex: Timber::Logger.new(STDOUT).")
166
+ end
167
+
168
+ @extra_loggers = io_devices_and_loggers[1..-1].collect do |obj|
169
+ if is_a_logger?(obj)
170
+ obj
171
+ else
172
+ self.class.new(obj)
173
+ end
166
174
  end
167
175
 
168
- @extra_loggers = io_devices[1..-1].collect { |io_device| self.class.new(io_device) }
169
- io_device = io_devices[0]
176
+ io_device = io_devices_and_loggers[0]
170
177
 
171
178
  super(io_device)
172
179
 
@@ -268,5 +275,9 @@ module Timber
268
275
  else; raise ArgumentError.new("level #{value.inspect} is not a valid logger level")
269
276
  end
270
277
  end
278
+
279
+ def is_a_logger?(obj)
280
+ obj.respond_to?(:debug) && obj.respond_to?(:info) && obj.respond_to?(:warn)
281
+ end
271
282
  end
272
283
  end
@@ -1,3 +1,3 @@
1
1
  module Timber
2
- VERSION = "2.2.3"
2
+ VERSION = "2.3.0"
3
3
  end
@@ -21,7 +21,7 @@ describe Timber::Logger, :rails_23 => true do
21
21
  end
22
22
  end
23
23
 
24
- it "should allow multiple loggers" do
24
+ it "should allow multiple io devices" do
25
25
  io1 = StringIO.new
26
26
  io2 = StringIO.new
27
27
  logger = Timber::Logger.new(STDOUT, io1, io2)
@@ -29,6 +29,18 @@ describe Timber::Logger, :rails_23 => true do
29
29
  expect(io1.string).to start_with("hello world @metadata {")
30
30
  expect(io2.string).to start_with("hello world @metadata {")
31
31
  end
32
+
33
+ it "should allow multiple io devices and loggers" do
34
+ io1 = StringIO.new
35
+ io2 = StringIO.new
36
+ io3 = StringIO.new
37
+ extra_logger = ::Logger.new(io3)
38
+ logger = Timber::Logger.new(STDOUT, io1, io2, extra_logger)
39
+ logger.info("hello world")
40
+ expect(io1.string).to start_with("hello world @metadata {")
41
+ expect(io2.string).to start_with("hello world @metadata {")
42
+ expect(io3.string).to end_with("hello world\n")
43
+ end
32
44
  end
33
45
 
34
46
  describe "#add" do
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.2.3
4
+ version: 2.3.0
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-09-19 00:00:00.000000000 Z
11
+ date: 2017-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: msgpack