lapine 0.2.7 → 0.2.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lapine/annotated_logger.rb +49 -46
- data/lib/lapine/consumer/runner.rb +1 -1
- data/lib/lapine/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1001cd5da440647b8239d6707856cc5cc9beece5
|
4
|
+
data.tar.gz: a96e6b8872ac1d2c97be49276f7f6e5b4e74eab1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 53c391e0bd380251371e3d34aa15eae90f487f2bcd916e01b10a48a2c20c1aa292dd57581ef69309fe2d2a93f489e1827a78a3e24ac2f072ff1ee97b15bcec33
|
7
|
+
data.tar.gz: f697bc707ed1cb0d60829610e5f2c3d78179532f30188f02ade417b94ccfbb1d3bf9977f7cb5d2140538d0142144a54f8d62e6d38d55fce22429088ba4095d5b
|
@@ -1,14 +1,16 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
require 'logger'
|
2
|
+
module Lapine
|
3
|
+
class AnnotatedLogger < Logger
|
4
|
+
attr_accessor :log_method_caller # if set will log ruby method name substring from where logging is called
|
5
|
+
attr_accessor :log_timestamps # if set will log timestamps up to millisecond
|
6
|
+
attr_accessor :colorize_logging # if set turns on colors (hint: turn off in production)
|
5
7
|
|
6
|
-
|
8
|
+
NUMBER_TO_COLOR_MAP = {"debug" => '0;37', "info" => '32', "warn" => '33', "error" => '31', "fatal" => '31', "unknown" => '37'}
|
7
9
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
10
|
+
def initialize *args
|
11
|
+
super *args
|
12
|
+
[:info, :debug, :warn, :error, :fatal].each { |m|
|
13
|
+
AnnotatedLogger.class_eval %Q!
|
12
14
|
def #{m} arg=nil, &block
|
13
15
|
level = "#{m}"
|
14
16
|
pid = "%.5d:" % $$
|
@@ -22,49 +24,50 @@ class AnnotatedLogger < Logger
|
|
22
24
|
super(l) if l
|
23
25
|
end
|
24
26
|
!
|
25
|
-
|
26
|
-
end
|
27
|
-
|
28
|
-
def log_message(t, pid, level, out)
|
29
|
-
color_on = color_off = sql_color_on = ""
|
30
|
-
if self.colorize_logging
|
31
|
-
color = NUMBER_TO_COLOR_MAP[level.to_s]
|
32
|
-
color_on = "\033[#{color}m"
|
33
|
-
sql_color_on = "\033[34m"
|
34
|
-
color_off = "\033[0m"
|
27
|
+
}
|
35
28
|
end
|
36
|
-
format_string = ""
|
37
|
-
format_values = []
|
38
|
-
if self.log_timestamps
|
39
|
-
format_string << "%s.%03d "
|
40
|
-
format_values << [t.strftime("%Y-%m-%d %H:%M:%S"), t.usec / 1000]
|
41
|
-
end
|
42
|
-
format_string << "%s #{color_on}%6.6s#{color_off} "
|
43
|
-
format_values << [pid, level]
|
44
29
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
30
|
+
def log_message(t, pid, level, out)
|
31
|
+
color_on = color_off = sql_color_on = ""
|
32
|
+
if self.colorize_logging
|
33
|
+
color = NUMBER_TO_COLOR_MAP[level.to_s]
|
34
|
+
color_on = "\033[#{color}m"
|
35
|
+
sql_color_on = "\033[34m"
|
36
|
+
color_off = "\033[0m"
|
37
|
+
end
|
38
|
+
format_string = ""
|
39
|
+
format_values = []
|
40
|
+
if self.log_timestamps
|
41
|
+
format_string << "%s.%03d "
|
42
|
+
format_values << [t.strftime("%Y-%m-%d %H:%M:%S"), t.usec / 1000]
|
43
|
+
end
|
44
|
+
format_string << "%s #{color_on}%6.6s#{color_off} "
|
45
|
+
format_values << [pid, level]
|
50
46
|
|
51
|
-
|
52
|
-
|
53
|
-
|
47
|
+
if self.log_method_caller
|
48
|
+
file, line, method = caller_method
|
49
|
+
format_string << "|%-40.40s "
|
50
|
+
format_values << "#{File.basename(file)}:#{line}:#{method}"
|
51
|
+
end
|
54
52
|
|
55
|
-
|
56
|
-
|
53
|
+
format_string << "%s"
|
54
|
+
format_values << [out]
|
55
|
+
format_values.flatten!
|
57
56
|
|
58
|
-
|
59
|
-
|
60
|
-
end
|
57
|
+
format_string % format_values
|
58
|
+
end
|
61
59
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
60
|
+
def caller_method
|
61
|
+
parse_caller(caller(3).first)
|
62
|
+
end
|
63
|
+
|
64
|
+
def parse_caller(at)
|
65
|
+
if /^(.+?):(\d+)(?::in `(.*)')?/ =~ at
|
66
|
+
file = Regexp.last_match[1]
|
67
|
+
line = Regexp.last_match[2].to_i
|
68
|
+
method = Regexp.last_match[3]
|
69
|
+
[file, line, method]
|
70
|
+
end
|
68
71
|
end
|
69
72
|
end
|
70
73
|
end
|
@@ -61,7 +61,7 @@ module Lapine
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def logger
|
64
|
-
@logger ||= config.logfile ? AnnotatedLogger.new(config.logfile) : AnnotatedLogger.new(STDOUT)
|
64
|
+
@logger ||= config.logfile ? ::Lapine::AnnotatedLogger.new(config.logfile) : ::Lapine::AnnotatedLogger.new(STDOUT)
|
65
65
|
end
|
66
66
|
|
67
67
|
def queue_properties
|
data/lib/lapine/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lapine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Saxby
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-12-
|
12
|
+
date: 2014-12-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: amqp
|