tracee 1.0.12 → 1.0.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: b5526f7b79e34c0574561b1eaee17258579ea0d0
4
- data.tar.gz: 6b4aa222a9ea306952c8b05a06c307e007c8cb92
3
+ metadata.gz: 619ff9514d9aaf865e6cdc037ac907cb65370eaa
4
+ data.tar.gz: 6c299eedba583c35c9bb6b61a9ee17692d998351
5
5
  SHA512:
6
- metadata.gz: 2f866cbba2e679818f266fe3e9739cc643cd51ed2c8935580f70374421e754003f859f9da3a703ca54f21ba5e6393718f1caa39439a3ee0b13938eeb3c29618c
7
- data.tar.gz: d924485d4b4773a2a3d37b2c106a77a4766cb99acbc7399fe6ad67d2f56676a6b208446b3649a4c77ad7cb6262bcf84001f58610f1532b2c851c4a07a8cabaf9
6
+ metadata.gz: 14e6cda31a2ce041ef3ee1ec6dcfdec183ae88618d0eabc13a0cf7670f2ac0d69e4c8c2e0d8bd4bd3703b844ff3c4fa0419bf82641ac1dd0eb78993bc916a6e8
7
+ data.tar.gz: 37ad87036bb943ab14186cdc78ee1b0629e28b0fb7f3fc16adda88b3c37e780040721a48a372fdcea299e06893a13ebe2d9d0c34113f564138e4a7cbd9b69f78
@@ -77,7 +77,15 @@ module Tracee
77
77
  end
78
78
 
79
79
  def level=(level)
80
- @level = level.is_a?(Integer) ? level : LEVELS.index(level.to_s.upcase)
80
+ Thread.current["tracee_#{__id__}_level"] = @level = norm_level(level)
81
+ end
82
+
83
+ def local_level=(level)
84
+ Thread.current["tracee_#{__id__}_level"] = norm_level(level)
85
+ end
86
+
87
+ def local_level
88
+ Thread.current["tracee_#{__id__}_level"] ||= @level
81
89
  end
82
90
 
83
91
  alias log_level= level=
@@ -108,7 +116,7 @@ module Tracee
108
116
 
109
117
  class_eval <<-EOS, __FILE__, __LINE__+1
110
118
  def #{level_name}(*args, &block)
111
- return if @level > #{level_int}
119
+ return if local_level > #{level_int}
112
120
 
113
121
  unless args[1].nil? or args[1].is_a?(Hash)
114
122
  raise TypeError, "\#{self.class.name}#\#{__callee__}'s second argument if given, is expected to be Hash. \#{args[1].class.name} is given."
@@ -152,8 +160,23 @@ module Tracee
152
160
  alias < warn
153
161
 
154
162
 
163
+ def silence(temporary_level=:error)
164
+ begin
165
+ old_local_level = local_level
166
+ self.local_level = temporary_level
167
+
168
+ yield self
169
+ ensure
170
+ self.local_level = old_local_level
171
+ end
172
+ end
173
+
155
174
  private
156
175
 
176
+ def norm_level(level)
177
+ level.is_a?(Integer) ? level : LEVELS.index(level.to_s.upcase)
178
+ end
179
+
157
180
  def read_log_level_from_env
158
181
  if ENV['LOG_LEVEL'] and LEVELS.include? ENV['LOG_LEVEL']
159
182
  self.log_level = ENV['LOG_LEVEL']
@@ -1,3 +1,3 @@
1
1
  module Tracee
2
- VERSION = "1.0.12"
2
+ VERSION = "1.0.13"
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.12
4
+ version: 1.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergey Baev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-20 00:00:00.000000000 Z
11
+ date: 2017-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler