ocean-rails 7.2.2 → 7.2.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,121 +1,121 @@
1
- require 'socket'
2
-
3
- #
4
- # This class is a drop-in replacement for the standard Rails logger. It is
5
- # used in production only and uses ZeroMQ as an intelligent, high-capacity
6
- # transport. ZeromqLogger implements enough of the Logger interface to allow
7
- # it to override the standard logger.
8
- #
9
- class ZeromqLogger
10
-
11
- attr_accessor :level, :formatter
12
-
13
- #
14
- # Obtains the IP of the current process, initialises the @logger object
15
- # by instantiating a ZeroLog object which then is used to set up the
16
- # log data sender.
17
- #
18
- def initialize
19
- super
20
- # Get info about our environment
21
- @ip = Socket.ip_address_list.detect{|intf| intf.ipv4_private?}.getnameinfo[0]
22
- # Find the log hosts
23
- f = File.join(Rails.root, "config/config.yml")
24
- cfg = YAML.load(ERB.new(File.read(f)).result)
25
- @log_hosts = cfg['LOG_HOSTS'].blank? ? cfg['production']['LOG_HOSTS'] : cfg['LOG_HOSTS']
26
- # Set up the logger
27
- @logger = ZeroLog.new "/tmp/sub_push_#{Process.pid}", @log_hosts
28
- @formatter = ::Logger::Formatter.new
29
- end
30
-
31
- #
32
- # Utility function which returns true if the current log level is +DEBUG+ or lower.
33
- #
34
- def debug?() @level <= 0; end
35
-
36
- #
37
- # Utility function which returns true if the current log level is +INFO+ or lower.
38
- #
39
- def info?() @level <= 1; end
40
-
41
- #
42
- # Utility function which returns true if the current log level is +WARN+ or lower.
43
- #
44
- def warn?() @level <= 2; end
45
-
46
- #
47
- # Utility function which returns true if the current log level is +ERROR+ or lower.
48
- #
49
- def error?() @level <= 3; end
50
-
51
- #
52
- # Utility function which returns true if the current log level is +FATAL+ or lower.
53
- #
54
- def fatal?() @level <= 4; end
55
-
56
-
57
- #
58
- # This is the core method to add new log messages to the Rails log. It does nothing
59
- # if the level of the message is lower than the current log level, or if the message
60
- # is blank. Otherwise it creates a JSON log message as a hash, with data for the
61
- # following keys:
62
- #
63
- # +timestamp+: The time in milliseconds since the start of the Unix epoch.
64
- #
65
- # +ip+: The IP of the logging entity.
66
- #
67
- # +pid+: The Process ID of the logging process.
68
- #
69
- # +service+: The name of the service.
70
- #
71
- # +level+: The log level of the message (0=debug, 1=info, 2=warn, etc).
72
- #
73
- # +msg+: The log message itself.
74
- #
75
- def add(level, msg)
76
- return true if level < @level
77
- return true if msg.blank?
78
- # Compensate for bug in Rails 4.2.x
79
- return true if msg =~ /Couldn't find template for digesting/
80
- data = { ip: @ip,
81
- pid: Process.pid,
82
- service: APP_NAME,
83
- level: level
84
- }
85
- data[:token] = Thread.current[:x_api_token] if Thread.current[:x_api_token].present?
86
- data[:username] = Thread.current[:username] if Thread.current[:username].present?
87
- data[:msg] = msg if msg.is_a?(String)
88
- data[:timestamp] = (Time.now.utc.to_f * 1000).to_i unless data[:timestamp]
89
- data[:metadata] = Thread.current[:metadata] if Thread.current[:metadata].present?
90
- data = data.merge msg if msg.is_a?(Hash)
91
- @logger.log data
92
- true
93
- end
94
-
95
-
96
- def debug(*args)
97
- return if args.blank?
98
- add 0, *args
99
- end
100
-
101
- def info(*args)
102
- return if args.blank?
103
- add 1, *args
104
- end
105
-
106
- def warn(*args)
107
- return if args.blank?
108
- add 2, *args
109
- end
110
-
111
- def error(*args)
112
- return if args.blank?
113
- add 3, *args
114
- end
115
-
116
- def fatal(*args)
117
- return if args.blank?
118
- add 4, *args
119
- end
120
-
121
- end
1
+ # require 'socket'
2
+ #
3
+ # #
4
+ # # This class is a drop-in replacement for the standard Rails logger. It is
5
+ # # used in production only and uses ZeroMQ as an intelligent, high-capacity
6
+ # # transport. ZeromqLogger implements enough of the Logger interface to allow
7
+ # # it to override the standard logger.
8
+ # #
9
+ # class ZeromqLogger
10
+ #
11
+ # attr_accessor :level, :formatter
12
+ #
13
+ # #
14
+ # # Obtains the IP of the current process, initialises the @logger object
15
+ # # by instantiating a ZeroLog object which then is used to set up the
16
+ # # log data sender.
17
+ # #
18
+ # def initialize
19
+ # super
20
+ # # Get info about our environment
21
+ # @ip = Socket.ip_address_list.detect{|intf| intf.ipv4_private?}.getnameinfo[0]
22
+ # # Find the log hosts
23
+ # f = File.join(Rails.root, "config/config.yml")
24
+ # cfg = YAML.load(ERB.new(File.read(f)).result)
25
+ # @log_hosts = cfg['LOG_HOSTS'].blank? ? cfg['production']['LOG_HOSTS'] : cfg['LOG_HOSTS']
26
+ # # Set up the logger
27
+ # @logger = ZeroLog.new "/tmp/sub_push_#{Process.pid}", @log_hosts
28
+ # @formatter = ::Logger::Formatter.new
29
+ # end
30
+ #
31
+ # #
32
+ # # Utility function which returns true if the current log level is +DEBUG+ or lower.
33
+ # #
34
+ # def debug?() @level <= 0; end
35
+ #
36
+ # #
37
+ # # Utility function which returns true if the current log level is +INFO+ or lower.
38
+ # #
39
+ # def info?() @level <= 1; end
40
+ #
41
+ # #
42
+ # # Utility function which returns true if the current log level is +WARN+ or lower.
43
+ # #
44
+ # def warn?() @level <= 2; end
45
+ #
46
+ # #
47
+ # # Utility function which returns true if the current log level is +ERROR+ or lower.
48
+ # #
49
+ # def error?() @level <= 3; end
50
+ #
51
+ # #
52
+ # # Utility function which returns true if the current log level is +FATAL+ or lower.
53
+ # #
54
+ # def fatal?() @level <= 4; end
55
+ #
56
+ #
57
+ # #
58
+ # # This is the core method to add new log messages to the Rails log. It does nothing
59
+ # # if the level of the message is lower than the current log level, or if the message
60
+ # # is blank. Otherwise it creates a JSON log message as a hash, with data for the
61
+ # # following keys:
62
+ # #
63
+ # # +timestamp+: The time in milliseconds since the start of the Unix epoch.
64
+ # #
65
+ # # +ip+: The IP of the logging entity.
66
+ # #
67
+ # # +pid+: The Process ID of the logging process.
68
+ # #
69
+ # # +service+: The name of the service.
70
+ # #
71
+ # # +level+: The log level of the message (0=debug, 1=info, 2=warn, etc).
72
+ # #
73
+ # # +msg+: The log message itself.
74
+ # #
75
+ # def add(level, msg)
76
+ # return true if level < @level
77
+ # return true if msg.blank?
78
+ # # Compensate for bug in Rails 4.2.x
79
+ # return true if msg =~ /Couldn't find template for digesting/
80
+ # data = { ip: @ip,
81
+ # pid: Process.pid,
82
+ # service: APP_NAME,
83
+ # level: level
84
+ # }
85
+ # data[:token] = Thread.current[:x_api_token] if Thread.current[:x_api_token].present?
86
+ # data[:username] = Thread.current[:username] if Thread.current[:username].present?
87
+ # data[:msg] = msg if msg.is_a?(String)
88
+ # data[:timestamp] = (Time.now.utc.to_f * 1000).to_i unless data[:timestamp]
89
+ # data[:metadata] = Thread.current[:metadata] if Thread.current[:metadata].present?
90
+ # data = data.merge msg if msg.is_a?(Hash)
91
+ # @logger.log data
92
+ # true
93
+ # end
94
+ #
95
+ #
96
+ # def debug(*args)
97
+ # return if args.blank?
98
+ # add 0, *args
99
+ # end
100
+ #
101
+ # def info(*args)
102
+ # return if args.blank?
103
+ # add 1, *args
104
+ # end
105
+ #
106
+ # def warn(*args)
107
+ # return if args.blank?
108
+ # add 2, *args
109
+ # end
110
+ #
111
+ # def error(*args)
112
+ # return if args.blank?
113
+ # add 3, *args
114
+ # end
115
+ #
116
+ # def fatal(*args)
117
+ # return if args.blank?
118
+ # add 4, *args
119
+ # end
120
+ #
121
+ # end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ocean-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.2.2
4
+ version: 7.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Bengtson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-16 00:00:00.000000000 Z
11
+ date: 2018-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: typhoeus