tlogger 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/tlogger/version.rb +1 -1
- data/lib/tlogger.rb +59 -17
- data/samples/basic2.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: adf500751775578bf59767ced9bb9c99aa9c818bc3c42545f9bb9141b410200b
|
4
|
+
data.tar.gz: 2c63441093ac202313c3286ba42d2866be74c99569e10a82a8797da7f7fd3c95
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33f79574622d9e61a7cfc0d61b6465f18ab740e1217240d89edee8502f8aa914a4b857a59e0f99f94fead0226873c06fca516501813148cd5c75bb517a0c688a
|
7
|
+
data.tar.gz: 474f8bd690784fe4461337ab3aeb5be59b6b5b8f67c20e86c6e39ffc994adf0a65a7721ec31ed328bdccfa4774c65e8caa403e36eaa4227c13bb684d7bfd05c8
|
data/Gemfile.lock
CHANGED
data/lib/tlogger/version.rb
CHANGED
data/lib/tlogger.rb
CHANGED
@@ -14,7 +14,7 @@ module Tlogger
|
|
14
14
|
#
|
15
15
|
class TloggerConf
|
16
16
|
include Singleton
|
17
|
-
attr_reader :active_tags, :scoped_tag, :blacklisted_tags, :
|
17
|
+
attr_reader :active_tags, :scoped_tag, :blacklisted_tags, :show_source
|
18
18
|
#GLOBAL_TAG = :global
|
19
19
|
GLOBAL_TAG = ""
|
20
20
|
INT_TAG = :tlogger
|
@@ -30,20 +30,37 @@ module Tlogger
|
|
30
30
|
@output_map = {}
|
31
31
|
# if output_map is there, then there should be pre created log file with specific output defined in the map. [<config>] => log_instance
|
32
32
|
@output_log = {}
|
33
|
+
# show where is the log being printed out. Like auto_tag output
|
34
|
+
@show_source = false
|
33
35
|
# end todo
|
34
36
|
end
|
35
37
|
|
36
|
-
def
|
37
|
-
@
|
38
|
+
def show_source
|
39
|
+
@show_source = true
|
38
40
|
end
|
41
|
+
alias_method :auto_tag_on, :show_source
|
39
42
|
|
40
|
-
def
|
41
|
-
@
|
43
|
+
def hide_source
|
44
|
+
@show_source = false
|
42
45
|
end
|
46
|
+
alias_method :auto_tag_off, :hide_source
|
43
47
|
|
44
|
-
def
|
45
|
-
@
|
48
|
+
def is_show_source?
|
49
|
+
@show_source
|
46
50
|
end
|
51
|
+
alias_method :is_auto_tag_on?, :is_show_source?
|
52
|
+
|
53
|
+
#def auto_tag_on
|
54
|
+
# @auto_tag = true
|
55
|
+
#end
|
56
|
+
|
57
|
+
#def auto_tag_off
|
58
|
+
# @auto_tag = false
|
59
|
+
#end
|
60
|
+
|
61
|
+
#def is_auto_tag_on?
|
62
|
+
# @auto_tag
|
63
|
+
#end
|
47
64
|
|
48
65
|
def activate_tag(tag)
|
49
66
|
@active_tags << tag
|
@@ -206,7 +223,13 @@ module Tlogger
|
|
206
223
|
if TloggerConf.has_scoped_tag?
|
207
224
|
if TloggerConf.is_scoped_tag_active?
|
208
225
|
intDebug("Scoped tag detected")
|
209
|
-
|
226
|
+
tag = []
|
227
|
+
tag << TloggerConf.scoped_tag
|
228
|
+
if TloggerConf.instance.is_show_source?
|
229
|
+
tag << " - "
|
230
|
+
tag << find_caller
|
231
|
+
end
|
232
|
+
args[0] = "[#{tag.join}] #{args[0]}"
|
210
233
|
@tlogger.send(mtd,*args,&block)
|
211
234
|
end
|
212
235
|
elsif TloggerConf.is_auto_tag_on?
|
@@ -215,7 +238,13 @@ module Tlogger
|
|
215
238
|
@tlogger.send(mtd,*args,&block)
|
216
239
|
elsif TloggerConf.is_tag_active?(@tag)
|
217
240
|
intDebug("Tagged output...")
|
218
|
-
|
241
|
+
tag = []
|
242
|
+
tag << @tag
|
243
|
+
if TloggerConf.instance.is_show_source?
|
244
|
+
tag << " - "
|
245
|
+
tag << find_caller
|
246
|
+
end
|
247
|
+
args[0] = "[#{tag.join}] #{args[0]}"
|
219
248
|
@tlogger.send(mtd,*args,&block)
|
220
249
|
end
|
221
250
|
|
@@ -242,22 +271,35 @@ module Tlogger
|
|
242
271
|
|
243
272
|
private
|
244
273
|
def tag_class(*args)
|
274
|
+
args[0] = "[#{find_caller}] #{args[0]}"
|
275
|
+
args
|
276
|
+
end
|
277
|
+
# end tag_class()
|
278
|
+
#
|
279
|
+
|
280
|
+
def find_caller
|
245
281
|
caller.each do |c|
|
246
282
|
next if c =~ /tlogger.rb/
|
247
283
|
@cal = c
|
248
284
|
break
|
249
285
|
end
|
286
|
+
|
287
|
+
if @cal.nil? or @cal.empty?
|
288
|
+
@cal = caller[0]
|
289
|
+
end
|
250
290
|
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
291
|
+
wd = Dir.getwd
|
292
|
+
indx = @cal =~ /#{wd}/
|
293
|
+
if indx != nil
|
294
|
+
@scal = []
|
295
|
+
@scal << @cal[0..indx]
|
296
|
+
@scal << @cal[indx+wd.length..-1]
|
297
|
+
@scal.join
|
298
|
+
else
|
299
|
+
@cal
|
255
300
|
end
|
256
|
-
|
257
|
-
args
|
258
|
-
#args[0] = "[#{@cal}] #{args[0]}"
|
259
301
|
end
|
260
|
-
# end
|
302
|
+
# end find_caller
|
261
303
|
#
|
262
304
|
end
|
263
305
|
#
|
data/samples/basic2.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tlogger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Liaw
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-08-
|
11
|
+
date: 2019-08-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|