tracee 1.0.19 → 1.0.20

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: 4b7301c5453f56f0ed92dc86667bf87ca0015ce8
4
- data.tar.gz: cfc9997287f44dacf8c95c4aa3c6f9bfadc090f8
3
+ metadata.gz: 557a7f67084c24ccd0866a9f586ec1ff803aae98
4
+ data.tar.gz: e4594457cab31e45f1d31b6f079bf52a0f8e8969
5
5
  SHA512:
6
- metadata.gz: a25658ffa6224edf4b12ebce0076f0d68d8b93002f52b940159214f08accc667d26e5fb502b3bdce76926b4e981a6163aaad487204ad3e8fbf490d882e924adc
7
- data.tar.gz: a40a9489ffa7128294874eaff7f0f26ffe8d9d4351503da8a97ac1fb6ef47b092594ea19b275d13a663fd93068882e6dd9116773775f03caf69cf86fcb90e05d
6
+ metadata.gz: e50641413455386a05c5ae3e9d69b7705e02704b66ed8e41a67670e5d455653514d5872aec0e266dc724bae9aa35c7c3d7ae541506081ca7fae84d6dc157dc28
7
+ data.tar.gz: 7aaf0979f7f73e3e5371acfb41dcb489508249cfa7ef5faa00d1a80b99b9e7eccc48b928ae42d7ac328d47f11e7b63a6cb5dbf89db43c3aef25310f97c5d092c
@@ -51,6 +51,9 @@ module Tracee
51
51
  mattr_accessor :better_errors_quiet_backtraces
52
52
  self.better_errors_quiet_backtraces = true
53
53
 
54
+ # Default logger to respond to Object#__log__
55
+ mattr_accessor :default_logger
56
+
54
57
  # In order to use Tracee's trace decorator with BetterErrors, Tracee must be loaded prior to BetterErrros.
55
58
  if defined? ::BetterErrors::ExceptionExtension
56
59
  # BetterErrors was loaded and BetterErrors::ExceptionExtension was prepended to Exception.
@@ -112,5 +115,5 @@ module Tracee
112
115
  end
113
116
 
114
117
 
115
- $log ||= Logger.new
118
+ $log ||= Logger.new default: true
116
119
  end
@@ -1,7 +1,9 @@
1
1
  class Object
2
2
 
3
3
  def __log__(caller_at: 0)
4
- $log.debug(caller_at: caller_at + 1) {inspect}
4
+ if Tracee.default_logger
5
+ Tracee.default_logger.debug(caller_at: caller_at + 1) {inspect}
6
+ end
5
7
  self
6
8
  end
7
9
 
@@ -17,7 +17,7 @@ module Tracee
17
17
  attr_reader :level, :preprocessors, :formatter, :streams
18
18
 
19
19
 
20
- def initialize(stream: $stdout, streams: nil, formatter: {:default => :plain}, preprocessors: [], level: :info)
20
+ def initialize(stream: $stdout, streams: nil, formatter: {:default => :plain}, preprocessors: [], level: :info, default: false)
21
21
  @streams = []
22
22
  streams ||= [stream]
23
23
  streams.each {|item| add_stream item}
@@ -40,6 +40,13 @@ module Tracee
40
40
 
41
41
  self.level = level
42
42
  read_log_level_from_env
43
+
44
+ if default
45
+ if Tracee.default_logger
46
+ warn "Overwriting default logger #{Tracee.default_logger}\nwith the new one: #{self}"
47
+ end
48
+ Tracee.default_logger = self
49
+ end
43
50
  end
44
51
 
45
52
 
@@ -175,6 +182,10 @@ module Tracee
175
182
  end
176
183
  end
177
184
 
185
+ def default?
186
+ Tracee.default_logger.eql? self
187
+ end
188
+
178
189
  private
179
190
 
180
191
  def norm_level(level)
@@ -1,3 +1,3 @@
1
1
  module Tracee
2
- VERSION = "1.0.19"
2
+ VERSION = '1.0.20'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tracee
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.19
4
+ version: 1.0.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergey Baev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-08 00:00:00.000000000 Z
11
+ date: 2018-05-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler