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 +4 -4
- data/CHANGELOG.md +8 -1
- data/README.md +1 -1
- data/lib/timber/logger.rb +19 -8
- data/lib/timber/version.rb +1 -1
- data/spec/timber/logger_spec.rb +13 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee78c33713b07a95e67fced3d964c9382ff1253d
|
4
|
+
data.tar.gz: cbcee8bd46fe73f4f2dfaf6f69562264609d7ec3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7a4583f3ca1a1bb634e45f2cbfc0d460e09daff20302226fe9465c9162efc471e6161eec6687f584741f7c4a84943f71076c598e2720b3b049d7975e8711712
|
7
|
+
data.tar.gz: 5b4fa450266005578ed20647067ee6694e5e6a1b79fd07c004a3e863e736072f92b7e9fa4a9feb660f4bfaf4b1fea8faa01ccc0ca2fccf68637658142ad0c697
|
data/CHANGELOG.md
CHANGED
@@ -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.
|
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
data/lib/timber/logger.rb
CHANGED
@@ -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
|
-
#
|
161
|
-
# logger = Timber::Logger.new(http_device,
|
162
|
-
def initialize(*
|
163
|
-
if
|
164
|
-
raise ArgumentError.new("At least one IO device must be provided when
|
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
|
-
|
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
|
data/lib/timber/version.rb
CHANGED
data/spec/timber/logger_spec.rb
CHANGED
@@ -21,7 +21,7 @@ describe Timber::Logger, :rails_23 => true do
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
it "should allow multiple
|
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.
|
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-
|
11
|
+
date: 2017-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: msgpack
|