ocean-rails 1.14.2 → 1.14.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ocean/version.rb +1 -1
- data/lib/ocean/zeromq_logger.rb +48 -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: b7f957055559e368f6cb0c7c449f46b957c68076
|
4
|
+
data.tar.gz: 9cb3d11b49d425bc45bd229929d46b43361e7f18
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0091f80cdf13da6d98ae0aa052de5eac75946e7569256242b72ad2a59ec442d89c3613e81ccc175fca80390944cdfb598b70f1757e069860772d50bbe4ffcb63
|
7
|
+
data.tar.gz: cb1f8e078078690ee7c88d4e662e3477128a451d84d9b32d5485b56c817b5bdf20d208cd2d2e66973c412aae0b9daf3af5bc40ff120dfcd0b2a0d70dfc4e0236
|
data/lib/ocean/version.rb
CHANGED
data/lib/ocean/zeromq_logger.rb
CHANGED
@@ -1,10 +1,21 @@
|
|
1
1
|
require 'socket'
|
2
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
|
+
#
|
3
9
|
class ZeromqLogger
|
4
10
|
|
5
11
|
attr_accessor :level, :log_tags
|
6
12
|
|
7
13
|
|
14
|
+
#
|
15
|
+
# Obtains the IP of the current process, initialises the @logger object
|
16
|
+
# by instantiating a ZeroLog object which then is used to set up the
|
17
|
+
# log data sender.
|
18
|
+
#
|
8
19
|
def initialize
|
9
20
|
super
|
10
21
|
# Get info about our environment
|
@@ -14,14 +25,50 @@ class ZeromqLogger
|
|
14
25
|
@logger.init_log_data_sender "/tmp/sub_push_#{Process.pid}"
|
15
26
|
end
|
16
27
|
|
17
|
-
|
28
|
+
#
|
29
|
+
# Utility function which returns true if the current log level is +DEBUG+ or lower.
|
30
|
+
#
|
18
31
|
def debug?() @level <= 0; end
|
32
|
+
|
33
|
+
#
|
34
|
+
# Utility function which returns true if the current log level is +INFO+ or lower.
|
35
|
+
#
|
19
36
|
def info?() @level <= 1; end
|
37
|
+
|
38
|
+
#
|
39
|
+
# Utility function which returns true if the current log level is +WARN+ or lower.
|
40
|
+
#
|
20
41
|
def warn?() @level <= 2; end
|
42
|
+
|
43
|
+
#
|
44
|
+
# Utility function which returns true if the current log level is +ERROR+ or lower.
|
45
|
+
#
|
21
46
|
def error?() @level <= 3; end
|
47
|
+
|
48
|
+
#
|
49
|
+
# Utility function which returns true if the current log level is +FATAL+ or lower.
|
50
|
+
#
|
22
51
|
def fatal?() @level <= 4; end
|
23
52
|
|
24
53
|
|
54
|
+
#
|
55
|
+
# This is the core method to add new log messages to the Rails log. It does nothing
|
56
|
+
# if the level of the message is lower than the current log level, or if the message
|
57
|
+
# is blank. Otherwise it creates a JSON log message as a hash, with data for the
|
58
|
+
# following keys:
|
59
|
+
#
|
60
|
+
# +timestamp+: The time in milliseconds since the start of the Unix epoch.
|
61
|
+
#
|
62
|
+
# +ip+: The IP of the logging entity.
|
63
|
+
#
|
64
|
+
# +pid+: The Process ID of the logging process.
|
65
|
+
#
|
66
|
+
# +service+: The name of the service.
|
67
|
+
#
|
68
|
+
# +level+: The log level of the message (0=debug, 1=info, 2=warn, etc).
|
69
|
+
#
|
70
|
+
# +msg+: The log message itself.
|
71
|
+
#
|
25
72
|
def add(level, msg, progname)
|
26
73
|
return true if level < @level
|
27
74
|
msg = progname if msg.blank?
|