timber 1.1.12 → 1.1.13
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c4f1205077f2126e3ee9c9c52b553f3a0b1fcf4
|
4
|
+
data.tar.gz: 85720eb2baac30ecb300bb959f4fb2ee743dadf7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce7dbd8e9bed79ee89273a4bf72543ea7b87ff737f934e2724e20f5ff2e4efc90ab6d51fc9e21c4892a3c17b78147327813c40dd37329f0172959863ef73457a
|
7
|
+
data.tar.gz: a18c9a9bbda731c1f87c4729230b3d5db7af1fd25828925ca9ccc04d47d4f14b11139f8df3da35e61948d4863760127ecbc004f07608a035409cf7248c50eb11
|
@@ -10,7 +10,13 @@ module Timber
|
|
10
10
|
def initialize(attributes)
|
11
11
|
@name = attributes[:name] || raise(ArgumentError.new(":name is required"))
|
12
12
|
@exception_message = attributes[:exception_message] || raise(ArgumentError.new(":exception_message is required"))
|
13
|
-
|
13
|
+
|
14
|
+
backtrace = attributes[:backtrace]
|
15
|
+
if backtrace.nil? || backtrace == []
|
16
|
+
raise(ArgumentError.new(":backtrace is required"))
|
17
|
+
end
|
18
|
+
|
19
|
+
@backtrace = backtrace.collect { |line| parse_backtrace_line(line) }
|
14
20
|
end
|
15
21
|
|
16
22
|
def to_hash
|
@@ -23,13 +29,16 @@ module Timber
|
|
23
29
|
end
|
24
30
|
|
25
31
|
def message
|
26
|
-
|
27
|
-
if backtrace.is_a?(Array) && backtrace.length > 0
|
28
|
-
message << "\n\n"
|
29
|
-
message << backtrace.join("\n")
|
30
|
-
end
|
31
|
-
message
|
32
|
+
"#{name} (#{exception_message})"
|
32
33
|
end
|
34
|
+
|
35
|
+
private
|
36
|
+
def parse_backtrace_line(line)
|
37
|
+
# using split for performance reasons
|
38
|
+
file, line, function_part = line.split(":", 3)
|
39
|
+
_prefix, function = function_part.split("`", 2)
|
40
|
+
{file: file, line: line.to_i, function: function.chomp("'")}
|
41
|
+
end
|
33
42
|
end
|
34
43
|
end
|
35
44
|
end
|
data/lib/timber/version.rb
CHANGED
data/spec/support/rails.rb
CHANGED
@@ -2,7 +2,7 @@ require "rails"
|
|
2
2
|
|
3
3
|
# Defualt the rails logger to nothing, each test shoould be
|
4
4
|
# responsible for setting up the logger
|
5
|
-
logger = ::Logger.new(
|
5
|
+
logger = ::Logger.new(STDOUT) # change to STDOUT to see rails logs
|
6
6
|
Rails.logger = logger
|
7
7
|
|
8
8
|
class RailsApp < Rails::Application
|
@@ -2,18 +2,23 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
describe Timber::Overrides::LoggerAdd, :rails_23 => true do
|
4
4
|
describe "#add" do
|
5
|
+
let(:io) { StringIO.new }
|
6
|
+
let(:logger) do
|
7
|
+
logger = ::Logger.new(io)
|
8
|
+
logger.formatter = proc do |severity, datetime, progname, msg|
|
9
|
+
"#{msg}\n"
|
10
|
+
end
|
11
|
+
logger
|
12
|
+
end
|
13
|
+
|
5
14
|
it "should display the message only when passed to a default logger" do
|
6
15
|
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
16
|
logger.info(event)
|
10
17
|
expect(io.string).to eq("Build version 1.0.0\n")
|
11
18
|
end
|
12
19
|
|
13
20
|
it "should work with blocks" do
|
14
21
|
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
22
|
logger.info { event }
|
18
23
|
expect(io.string).to eq("Build version 1.0.0\n")
|
19
24
|
end
|
@@ -37,9 +37,8 @@ describe Timber::Probes::ActionDispatchDebugExceptions do
|
|
37
37
|
mock_class
|
38
38
|
dispatch_rails_request("/exception")
|
39
39
|
# Because constantly updating the line numbers sucks :/
|
40
|
-
expect(io.string).to include("RuntimeError (boom)
|
41
|
-
expect(io.string).to include("
|
42
|
-
expect(io.string).to include("\"event\":{\"server_side_app\":{\"exception\":{\"name\":\"RuntimeError\",\"message\":\"boom\",\"backtrace\":[\"")
|
40
|
+
expect(io.string).to include("RuntimeError (boom) @metadata")
|
41
|
+
expect(io.string).to include("\"event\":{\"server_side_app\":{\"exception\":{\"name\":\"RuntimeError\",\"message\":\"boom\",\"backtrace\":[{\"file\":\"lib/timber/probes/action_controller_user_context.rb\",\"line\":33,\"function\":\"_timber_capture_user_context\"},")
|
43
42
|
end
|
44
43
|
|
45
44
|
def mock_class
|
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: 1.1.
|
4
|
+
version: 1.1.13
|
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-03-
|
11
|
+
date: 2017-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: msgpack
|