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: ade6b71eaa06bca6d7cb9ff1a551fcbfd64d0052
4
- data.tar.gz: 704576249bdd4e7a281f26a2b291180e40adeb6b
3
+ metadata.gz: 2c4f1205077f2126e3ee9c9c52b553f3a0b1fcf4
4
+ data.tar.gz: 85720eb2baac30ecb300bb959f4fb2ee743dadf7
5
5
  SHA512:
6
- metadata.gz: f068e2c366402a47b9d7f88d70b25c4e2e007f1c5bdb59ec611d17c59aa129152cfea39a805e0059500a4d493e54285a6c2cb6fa450d9cb54227447e1a32d25d
7
- data.tar.gz: 1e2ea1d6268b5a0ab041448e8912e9eca0d31c6ea0a06b6b449d2d557bc83f8265f9afb4dd3802139cefdb8f00a6334f7f3d0e8d4696c028227047ace980edfe
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
- @backtrace = attributes[:backtrace]
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
- message = "#{name} (#{exception_message}):"
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
@@ -1,3 +1,3 @@
1
1
  module Timber
2
- VERSION = "1.1.12"
2
+ VERSION = "1.1.13"
3
3
  end
@@ -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(nil) # change to STDOUT to see rails logs
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):\\n\\n")
41
- expect(io.string).to include("@metadata")
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.12
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-01 00:00:00.000000000 Z
11
+ date: 2017-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: msgpack