enhanced-logger 0.1.8 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/enhanced_logger/logger.rb +17 -4
- data/lib/enhanced_logger/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b5001d91ed29d8b56e9e6d13f85b7b549d381c4
|
4
|
+
data.tar.gz: 4f10b05e495d9adf5d34322329d66e304565321c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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,
|
8
|
+
def initialize level=1, options=nil
|
9
|
+
options ||= {}
|
10
|
+
@options = {}
|
11
|
+
|
8
12
|
@level = level
|
9
|
-
@exclude_files = Array(
|
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
|
-
|
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
|