enhanced-logger 0.1.8 → 0.2.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
  SHA1:
3
- metadata.gz: e8e992520d6ea4d99f620cf37d8173b4ac8fd6b5
4
- data.tar.gz: 902f487e2f6d6917b458313e3dd4d353051c39ae
3
+ metadata.gz: 4b5001d91ed29d8b56e9e6d13f85b7b549d381c4
4
+ data.tar.gz: 4f10b05e495d9adf5d34322329d66e304565321c
5
5
  SHA512:
6
- metadata.gz: 2565dfbb3d10551fb9fcf6c7da44626134eef02208492c4699a6df208f818b02c71e254f7b2e4377d77ff0e55339e8f6972136b217cc41ee8ad3a10d6a0908fc
7
- data.tar.gz: b051cdc8fd1dfd94cb3d403daeb7658dd0673c7ac941934c3fd2e298f3e5b6d42746bb4355028e8bc6a319dce929a35b316465e27e6117925028286cd2d4014e
6
+ metadata.gz: 60173ff1c3ca9ce3ddabc84f1977cb19e070f3945db9362d0a0a8c0e562d01fe787df4d0fdf696422749ac4ae68ed0ddc5d5e884e16925d09450d541034b3a24
7
+ data.tar.gz: 64596c4f0c23280f145d2da644dcd08d6e1c4ea4905e2c9ab65118014de90824605acf344e833691418999d1f8067ef24c52786c9e58bc82c8417b524b9b687b
@@ -1,12 +1,18 @@
1
1
  module EnhancedLogger
2
2
  class Logger
3
3
  LEVELS = { debug:0, info:1, warn:2, error:3, fatal:4, unknown:5 }.freeze
4
+ MAX_UUID_LENGTH = 64
4
5
 
5
6
  attr_accessor :level
6
7
 
7
- def initialize level=1, params={}
8
+ def initialize level=1, options=nil
9
+ options ||= {}
10
+ @options = {}
11
+
8
12
  @level = level
9
- @exclude_files = Array( params[ :exclude_files ]).push filename
13
+ @options[ :exclude_files ] = Array( options[ :exclude_files ]).push filename
14
+ @options[ :uuid_log_length ] = options[ :uuid_log_length ]
15
+
10
16
  $stdout.sync = true
11
17
  end
12
18
 
@@ -66,7 +72,7 @@ module EnhancedLogger
66
72
  end
67
73
 
68
74
  def most_recent_caller
69
- regex_str = '[' + @exclude_files.join( '|' ) + ']'
75
+ regex_str = '[' + @options[ :exclude_files ].join( '|' ) + ']'
70
76
 
71
77
  caller.find{| c | c !~ %r+#{ regex_str }\.rb+ }.split( '/' ).last
72
78
  end
@@ -83,7 +89,14 @@ module EnhancedLogger
83
89
  parts = previous.split( /[\.|:]/ )
84
90
  method = previous.split( /`/ ).last.gsub( "'", "" )
85
91
 
86
- "#{ @remote_request_id } #{ @request_id } #{ parts[ 0 ]} #{ method } #{ parts[ 2 ]}: #{ msg }"
92
+ remote_request_id = @remote_request_id.to_s[ 0..uuid_log_length-1 ]
93
+ request_id = @request_id.to_s[ 0..uuid_log_length-1 ]
94
+
95
+ "#{ remote_request_id } #{ request_id } #{ parts[ 0 ]} #{ method } #{ parts[ 2 ]}: #{ msg }"
96
+ end
97
+
98
+ def uuid_log_length
99
+ @options[ :uuid_log_length ] || MAX_UUID_LENGTH
87
100
  end
88
101
  end
89
102
  end
@@ -1,3 +1,3 @@
1
1
  module EnhancedLogger
2
- VERSION = "0.1.8"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enhanced-logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - George Ulmer