lapine 0.2.7 → 0.2.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: df9e189850c444c60fc06be5f3054c162b518c81
4
- data.tar.gz: 42e8387e0ea8d7928774149fda5be0c3710ffc05
3
+ metadata.gz: 1001cd5da440647b8239d6707856cc5cc9beece5
4
+ data.tar.gz: a96e6b8872ac1d2c97be49276f7f6e5b4e74eab1
5
5
  SHA512:
6
- metadata.gz: 92b0b5edbc3bb1babdaf4d24a1dd3d50fe11233add45c8b5fcb6e0d97c9baf83a7e8510db06a948f6dd70dc9b1c788a643d6f0c2c4fafdd0160c6e24c50c039f
7
- data.tar.gz: 3078a27dd0766c1af133801e4eb82f957847f099615221bcb8745cb17524cbc7b73334584fcc65fd7f19a62009f8ef35a44062b9bacdff3bd82ccb7cdc19ef9f
6
+ metadata.gz: 53c391e0bd380251371e3d34aa15eae90f487f2bcd916e01b10a48a2c20c1aa292dd57581ef69309fe2d2a93f489e1827a78a3e24ac2f072ff1ee97b15bcec33
7
+ data.tar.gz: f697bc707ed1cb0d60829610e5f2c3d78179532f30188f02ade417b94ccfbb1d3bf9977f7cb5d2140538d0142144a54f8d62e6d38d55fce22429088ba4095d5b
@@ -1,14 +1,16 @@
1
- class AnnotatedLogger < Logger
2
- attr_accessor :log_method_caller # if set will log ruby method name substring from where logging is called
3
- attr_accessor :log_timestamps # if set will log timestamps up to millisecond
4
- attr_accessor :colorize_logging # if set turns on colors (hint: turn off in production)
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
- NUMBER_TO_COLOR_MAP = {"debug"=>'0;37', "info"=>'32', "warn"=>'33', "error"=>'31', "fatal"=>'31', "unknown"=>'37'}
8
+ NUMBER_TO_COLOR_MAP = {"debug" => '0;37', "info" => '32', "warn" => '33', "error" => '31', "fatal" => '31', "unknown" => '37'}
7
9
 
8
- def initialize *args
9
- super *args
10
- [:info, :debug, :warn, :error, :fatal].each { |m|
11
- AnnotatedLogger.class_eval %Q!
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
- if self.log_method_caller
46
- file, line, method = caller_method
47
- format_string << "|%-40.40s "
48
- format_values << "#{File.basename(file)}:#{line}:#{method}"
49
- end
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
- format_string << "%s"
52
- format_values << [out]
53
- format_values.flatten!
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
- format_string % format_values
56
- end
53
+ format_string << "%s"
54
+ format_values << [out]
55
+ format_values.flatten!
57
56
 
58
- def caller_method
59
- parse_caller(caller(3).first)
60
- end
57
+ format_string % format_values
58
+ end
61
59
 
62
- def parse_caller(at)
63
- if /^(.+?):(\d+)(?::in `(.*)')?/ =~ at
64
- file = Regexp.last_match[1]
65
- line = Regexp.last_match[2].to_i
66
- method = Regexp.last_match[3]
67
- [file, line, method]
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
@@ -1,3 +1,3 @@
1
1
  module Lapine
2
- VERSION = '0.2.7'
2
+ VERSION = '0.2.8'
3
3
  end
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.7
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-23 00:00:00.000000000 Z
12
+ date: 2014-12-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: amqp