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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 81d536a6b52ad6b35e449b2a19b92d72c16310f6bcb8214b4fce73e4b32785f7
4
- data.tar.gz: 4fc37ffecf6133063994e87ae8689641a391f545b52965f37aa28fa3ec316fca
3
+ metadata.gz: adf500751775578bf59767ced9bb9c99aa9c818bc3c42545f9bb9141b410200b
4
+ data.tar.gz: 2c63441093ac202313c3286ba42d2866be74c99569e10a82a8797da7f7fd3c95
5
5
  SHA512:
6
- metadata.gz: 7ca899db52484b56c039954d196a563c133f5d9d19d0c0c2d1617c92ef3d8974632721f0461db718a2ba2d3588b005502b6ce610cbe7d9de84c55982fa3aa7a7
7
- data.tar.gz: a59e8c857a39769189c98f97dc92d7405268dca08655f85d14eb855164fc936cbd338865bd48bea8c2b418226ff43abb398df99a9064370b80dc58755ba41fac
6
+ metadata.gz: 33f79574622d9e61a7cfc0d61b6465f18ab740e1217240d89edee8502f8aa914a4b857a59e0f99f94fead0226873c06fca516501813148cd5c75bb517a0c688a
7
+ data.tar.gz: 474f8bd690784fe4461337ab3aeb5be59b6b5b8f67c20e86c6e39ffc994adf0a65a7721ec31ed328bdccfa4774c65e8caa403e36eaa4227c13bb684d7bfd05c8
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tlogger (0.4)
4
+ tlogger (0.5.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,3 +1,3 @@
1
1
  module Tlogger
2
- VERSION = "0.5.0"
2
+ VERSION = "0.6.0"
3
3
  end
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, :auto_tag
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 auto_tag_on
37
- @auto_tag = true
38
+ def show_source
39
+ @show_source = true
38
40
  end
41
+ alias_method :auto_tag_on, :show_source
39
42
 
40
- def auto_tag_off
41
- @auto_tag = false
43
+ def hide_source
44
+ @show_source = false
42
45
  end
46
+ alias_method :auto_tag_off, :hide_source
43
47
 
44
- def is_auto_tag_on?
45
- @auto_tag
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
- args[0] = "[#{TloggerConf.scoped_tag}] #{args[0]}"
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
- args[0] = "[#{@tag}] #{args[0]}"
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
- if not @cal.nil? and not @cal.empty?
252
- wd = Dir.getwd
253
- @scal = @cal[wd.length..-1]
254
- args[0] = "[#{@scal}] #{args[0]}"
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 tag_class()
302
+ # end find_caller
261
303
  #
262
304
  end
263
305
  #
data/samples/basic2.rb CHANGED
@@ -7,6 +7,7 @@ l.tag = "dance"
7
7
  l.debug "here"
8
8
 
9
9
  #Tlogger::TloggerConf.blacklist_tag("jan")
10
+ Tlogger::TloggerConf.show_source
10
11
 
11
12
  l.with_tag 'jan' do
12
13
  l.debug "inside"
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.5.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-15 00:00:00.000000000 Z
11
+ date: 2019-08-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler