timber 1.1.11 → 1.1.12

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: 04d27a972b601ecae982beff3a8c0fcd6bb46294
4
- data.tar.gz: ae3ef7225f3127618d06f831bbd00e874585826a
3
+ metadata.gz: ade6b71eaa06bca6d7cb9ff1a551fcbfd64d0052
4
+ data.tar.gz: 704576249bdd4e7a281f26a2b291180e40adeb6b
5
5
  SHA512:
6
- metadata.gz: 29b027106869a5c1f3f68d46eecaaff96c7549b1bb03fa2916ca16704ca687e27c17f1842484f80e6c694fc608a31e387417c12556c6b2a8da0274577d55fb5c
7
- data.tar.gz: 1dca319df6e3b7523da304ee6009422230b583dde0b9482616027afc11de8d4dd8d6b530afc1001b3471dd0105d824182fc4f9bdbb4142ab671f937a246e3e9c
6
+ metadata.gz: f068e2c366402a47b9d7f88d70b25c4e2e007f1c5bdb59ec611d17c59aa129152cfea39a805e0059500a4d493e54285a6c2cb6fa450d9cb54227447e1a32d25d
7
+ data.tar.gz: 1e2ea1d6268b5a0ab041448e8912e9eca0d31c6ea0a06b6b449d2d557bc83f8265f9afb4dd3802139cefdb8f00a6334f7f3d0e8d4696c028227047ace980edfe
@@ -3,7 +3,7 @@ module Timber
3
3
  # `Logger` and the log device that you set it up with.
4
4
  class LogEntry #:nodoc:
5
5
  DT_PRECISION = 6.freeze
6
- SCHEMA = "https://raw.githubusercontent.com/timberio/log-event-json-schema/1.2.5/schema.json".freeze
6
+ SCHEMA = "https://raw.githubusercontent.com/timberio/log-event-json-schema/1.2.6/schema.json".freeze
7
7
 
8
8
  attr_reader :context_snapshot, :event, :level, :message, :progname, :tags, :time, :time_ms
9
9
 
@@ -0,0 +1,41 @@
1
+ module Timber
2
+ module Overrides
3
+ module LoggerAdd
4
+ def self.included(klass)
5
+ klass.class_eval do
6
+ alias_method :_timber_original_add, :add
7
+
8
+ def add(severity, message = nil, progname = nil)
9
+ # Extract the message: https://github.com/ruby/ruby/blob/f6e77b9d3555c1fbaa8aab1cdc0bd6bde95f62c6/lib/logger.rb#L461-L468
10
+ progname ||= @progname
11
+ if message.nil?
12
+ if block_given?
13
+ message = yield
14
+ else
15
+ message = progname
16
+ progname = @progname
17
+ end
18
+ end
19
+
20
+ if message.is_a?(::Timber::Event)
21
+ if self.is_a?(::Timber::Logger)
22
+ _timber_original_add(severity, message, progname)
23
+ else
24
+ if message.message.nil?
25
+ STDOUT.write message.inspect
26
+ end
27
+ _timber_original_add(severity, message.message, progname)
28
+ end
29
+ else
30
+ _timber_original_add(severity, message, progname)
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+
39
+ require "logger"
40
+
41
+ ::Logger.send(:include, Timber::Overrides::LoggerAdd)
@@ -1,3 +1,3 @@
1
1
  module Timber
2
- VERSION = "1.1.11"
2
+ VERSION = "1.1.12"
3
3
  end
@@ -0,0 +1,10 @@
1
+ require "spec_helper"
2
+
3
+ describe Timber::Event, :rails_23 => true do
4
+ describe "#to_s" do
5
+ it "should display the message" do
6
+ event = Timber::Events::Custom.new(message: "Build version 1.0.0", type: :build, data: {version: "1.0.0"})
7
+ expect(event.to_s).to eq("Build version 1.0.0")
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,21 @@
1
+ require "spec_helper"
2
+
3
+ describe Timber::Overrides::LoggerAdd, :rails_23 => true do
4
+ describe "#add" do
5
+ it "should display the message only when passed to a default logger" do
6
+ event = Timber::Events::Custom.new(message: "Build version 1.0.0", type: :build, data: {version: "1.0.0"})
7
+ io = StringIO.new
8
+ logger = ::Logger.new(io)
9
+ logger.info(event)
10
+ expect(io.string).to eq("Build version 1.0.0\n")
11
+ end
12
+
13
+ it "should work with blocks" do
14
+ event = Timber::Events::Custom.new(message: "Build version 1.0.0", type: :build, data: {version: "1.0.0"})
15
+ io = StringIO.new
16
+ logger = ::Logger.new(io)
17
+ logger.info { event }
18
+ expect(io.string).to eq("Build version 1.0.0\n")
19
+ end
20
+ end
21
+ end
@@ -36,14 +36,13 @@ describe Timber::Probes::ActiveRecordLogSubscriber do
36
36
 
37
37
  it "should log the sql query" do
38
38
  User.order("users.id DESC").all.collect # collect kicks the sql because it is lazily executed
39
- message = " \e[1m\e[36mUser Load (0.0ms)\e[0m \e[1m\e[34mSELECT \"users\".* FROM \"users\" ORDER BY users.id DESC\e[0m @metadata {\"level\":\"debug\",\"dt\":\"2016-09-01T12:00:00.000000Z\",\"event\":{\"sql_query\":{\"sql\":\"SELECT \\\"users\\\".* FROM \\\"users\\\" ORDER BY users.id DESC\",\"time_ms\":0.0}}}\n"
40
39
  # Rails 4.X adds random spaces :/
41
40
  string = io.string.gsub(" ORDER BY", " ORDER BY")
42
41
  string = string.gsub(" ORDER BY", " ORDER BY")
43
42
  expect(string).to include("users.id DESC")
44
43
  expect(string).to include("@metadata")
45
44
  expect(string).to include("\"level\":\"debug\"")
46
- expect(string).to include("\"sql\":")
45
+ expect(string).to include("\"event\":{\"server_side_app\":{\"sql_query\"")
47
46
  end
48
47
  end
49
48
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: timber
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.11
4
+ version: 1.1.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Timber Technologies, Inc.
@@ -79,6 +79,7 @@ files:
79
79
  - lib/timber/log_devices/http.rb
80
80
  - lib/timber/log_entry.rb
81
81
  - lib/timber/logger.rb
82
+ - lib/timber/overrides/logger_add.rb
82
83
  - lib/timber/overrides/rails_stdout_logging.rb
83
84
  - lib/timber/probe.rb
84
85
  - lib/timber/probes.rb
@@ -119,11 +120,13 @@ files:
119
120
  - spec/timber/contexts/system_spec.rb
120
121
  - spec/timber/contexts/user_spec.rb
121
122
  - spec/timber/contexts_spec.rb
123
+ - spec/timber/event_spec.rb
122
124
  - spec/timber/events/custom_spec.rb
123
125
  - spec/timber/events_spec.rb
124
126
  - spec/timber/log_devices/http_spec.rb
125
127
  - spec/timber/log_entry_spec.rb
126
128
  - spec/timber/logger_spec.rb
129
+ - spec/timber/overrides/logger_add_spec.rb
127
130
  - spec/timber/probes/action_controller_log_subscriber_spec.rb
128
131
  - spec/timber/probes/action_controller_user_context_spec.rb
129
132
  - spec/timber/probes/action_dispatch_debug_exceptions_spec.rb
@@ -175,11 +178,13 @@ test_files:
175
178
  - spec/timber/contexts/system_spec.rb
176
179
  - spec/timber/contexts/user_spec.rb
177
180
  - spec/timber/contexts_spec.rb
181
+ - spec/timber/event_spec.rb
178
182
  - spec/timber/events/custom_spec.rb
179
183
  - spec/timber/events_spec.rb
180
184
  - spec/timber/log_devices/http_spec.rb
181
185
  - spec/timber/log_entry_spec.rb
182
186
  - spec/timber/logger_spec.rb
187
+ - spec/timber/overrides/logger_add_spec.rb
183
188
  - spec/timber/probes/action_controller_log_subscriber_spec.rb
184
189
  - spec/timber/probes/action_controller_user_context_spec.rb
185
190
  - spec/timber/probes/action_dispatch_debug_exceptions_spec.rb