enhanced-logger 0.0.5 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/enhanced_logger/logger.rb +60 -0
- data/lib/enhanced_logger.rb +9 -2
- metadata +2 -2
- data/lib/models/enhanced_logger.rb +0 -58
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9d8369613157a66b87153d9684931e43f488921
|
4
|
+
data.tar.gz: 6a843dd23d387d6f0947e8cc4c2fbca08aa8d4ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 598fa73ee321fab5324a4d50fb0fb66809cd0d227e3a459bb3cb9a15019d9f740cd8a7d07742efd291cd0735a0f67e130cbb185975f90149fffc715746505786
|
7
|
+
data.tar.gz: 620a4eec5232bf30b25581f38d8d9079fc3bf0355f4d461e914d0255a26f3220eae8be9de269797fe97737380ce6a26856f959f51c76eceda2517c4109fe8440
|
@@ -0,0 +1,60 @@
|
|
1
|
+
puts 'EnhancedLogger loaded...'
|
2
|
+
|
3
|
+
module EnhancedLogger
|
4
|
+
class Logger
|
5
|
+
attr_accessor :level
|
6
|
+
|
7
|
+
def initialize dest
|
8
|
+
$stdout.sync = true
|
9
|
+
end
|
10
|
+
|
11
|
+
def set_env env
|
12
|
+
@request_id = env[ 'HTTP_X_REQUEST_ID' ]
|
13
|
+
@remote_request_id = env[ 'HTTP_X_REMOTE_REQUEST_ID' ]
|
14
|
+
end
|
15
|
+
|
16
|
+
def clear_env
|
17
|
+
end
|
18
|
+
|
19
|
+
def info msg = nil
|
20
|
+
return unless msg
|
21
|
+
|
22
|
+
puts formatted( msg )
|
23
|
+
end
|
24
|
+
|
25
|
+
def info?
|
26
|
+
true
|
27
|
+
end
|
28
|
+
|
29
|
+
def debug?
|
30
|
+
true
|
31
|
+
end
|
32
|
+
|
33
|
+
def debug msg
|
34
|
+
puts formatted( msg )
|
35
|
+
end
|
36
|
+
|
37
|
+
def error msg
|
38
|
+
puts formatted( msg )
|
39
|
+
end
|
40
|
+
|
41
|
+
def fatal msg
|
42
|
+
puts formatted( msg )
|
43
|
+
end
|
44
|
+
|
45
|
+
def formatter
|
46
|
+
''
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def formatted msg
|
53
|
+
previous = caller[ 1 ].split( '/' ).last
|
54
|
+
parts = previous.split( /[\.|:]/ )
|
55
|
+
method = previous.split( /`/ ).last.gsub( "'", "" )
|
56
|
+
|
57
|
+
"#{ @remote_request_id } #{ @request_id } #{ parts[ 0 ]} #{ method } #{ parts[ 2 ]}: #{ msg }"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
data/lib/enhanced_logger.rb
CHANGED
@@ -1,4 +1,11 @@
|
|
1
|
-
|
2
|
-
require '
|
1
|
+
module EnhancedLogger
|
2
|
+
require 'enhanced_logger/logger'
|
3
|
+
|
4
|
+
if defined?(Rails)
|
5
|
+
require 'rails/application_controller'
|
6
|
+
else
|
7
|
+
# require 'our_gem/difficult_stuff'
|
8
|
+
end
|
9
|
+
end
|
3
10
|
|
4
11
|
puts 'Loading Enhanced Logger.'
|
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.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- George Ulmer
|
@@ -17,7 +17,7 @@ extensions: []
|
|
17
17
|
extra_rdoc_files: []
|
18
18
|
files:
|
19
19
|
- lib/enhanced_logger.rb
|
20
|
-
- lib/
|
20
|
+
- lib/enhanced_logger/logger.rb
|
21
21
|
- lib/rails/application_controller.rb
|
22
22
|
homepage: http://rubygems.org/gems/enhanced_logger
|
23
23
|
licenses:
|
@@ -1,58 +0,0 @@
|
|
1
|
-
puts 'EnhancedLogger loaded...'
|
2
|
-
|
3
|
-
class EnhancedLogger
|
4
|
-
attr_accessor :level
|
5
|
-
|
6
|
-
def initialize dest
|
7
|
-
$stdout.sync = true
|
8
|
-
end
|
9
|
-
|
10
|
-
def set_env env
|
11
|
-
@request_id = env[ 'HTTP_X_REQUEST_ID' ]
|
12
|
-
@remote_request_id = env[ 'HTTP_X_REMOTE_REQUEST_ID' ]
|
13
|
-
end
|
14
|
-
|
15
|
-
def clear_env
|
16
|
-
end
|
17
|
-
|
18
|
-
def info msg = nil
|
19
|
-
return unless msg
|
20
|
-
|
21
|
-
puts formatted( msg )
|
22
|
-
end
|
23
|
-
|
24
|
-
def info?
|
25
|
-
true
|
26
|
-
end
|
27
|
-
|
28
|
-
def debug?
|
29
|
-
true
|
30
|
-
end
|
31
|
-
|
32
|
-
def debug msg
|
33
|
-
puts formatted( msg )
|
34
|
-
end
|
35
|
-
|
36
|
-
def error msg
|
37
|
-
puts formatted( msg )
|
38
|
-
end
|
39
|
-
|
40
|
-
def fatal msg
|
41
|
-
puts formatted( msg )
|
42
|
-
end
|
43
|
-
|
44
|
-
def formatter
|
45
|
-
''
|
46
|
-
end
|
47
|
-
|
48
|
-
|
49
|
-
private
|
50
|
-
|
51
|
-
def formatted msg
|
52
|
-
previous = caller[ 1 ].split( '/' ).last
|
53
|
-
parts = previous.split( /[\.|:]/ )
|
54
|
-
method = previous.split( /`/ ).last.gsub( "'", "" )
|
55
|
-
|
56
|
-
"#{ @remote_request_id } #{ @request_id } #{ parts[ 0 ]} #{ method } #{ parts[ 2 ]}: #{ msg }"
|
57
|
-
end
|
58
|
-
end
|