rsmp 0.5.5 → 0.5.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/config/supervisor.yaml +2 -1
- data/config/tlc.yaml +3 -2
- data/lib/rsmp/logger.rb +70 -49
- data/lib/rsmp/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 22ab99646f7155eb2bd6cd2f39923f499f7fa5b019f63a5124886bc1ef4cbb15
|
4
|
+
data.tar.gz: db75cb477bfe945f799f37108a33550b4251d05b3d1a4f225e962dad16a4c827
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c311032b06dab4f4d0aeb3a1ce61c961b87125546116eba2429bce01f3cdb5bcd0a9bf0bbe037dedb6c0cea2e269926cc180be51823bcddddebe89bde55c273f
|
7
|
+
data.tar.gz: 3121265aa3f49f49131a4afe7fe2479bcad25b2be74bcfaabb89ef8cf485cbae20298a33df456913c5818f160d0fa1e5ce7adf8142cbdac962cd109e8b13fd66
|
data/Gemfile.lock
CHANGED
data/config/supervisor.yaml
CHANGED
data/config/tlc.yaml
CHANGED
data/lib/rsmp/logger.rb
CHANGED
@@ -5,33 +5,60 @@ module RSMP
|
|
5
5
|
|
6
6
|
def initialize settings={}
|
7
7
|
defaults = {
|
8
|
-
'prefix'=>nil,
|
9
8
|
'active'=>false,
|
10
9
|
'path'=>nil,
|
11
10
|
'stream'=>nil,
|
12
|
-
'author'=>false,
|
13
11
|
'color'=>true,
|
14
|
-
'site_id'=>true,
|
15
|
-
'component'=>false,
|
16
|
-
'level'=>false,
|
17
|
-
'ip'=>false,
|
18
|
-
'port'=>false,
|
19
|
-
'index'=>false,
|
20
|
-
'timestamp'=>true,
|
21
|
-
'json'=>false,
|
22
12
|
'debug'=>false,
|
23
13
|
'statistics'=>false,
|
24
14
|
'hide_ip_and_port' => false,
|
25
|
-
'acknowledgements' => false
|
15
|
+
'acknowledgements' => false,
|
16
|
+
'json'=>false,
|
17
|
+
'tabs'=>'-',
|
18
|
+
|
19
|
+
'prefix'=>false,
|
20
|
+
'index'=>false,
|
21
|
+
'author'=>false,
|
22
|
+
'timestamp'=>true,
|
23
|
+
'ip'=>false,
|
24
|
+
'port'=>false,
|
25
|
+
'site_id'=>true,
|
26
|
+
'component_id'=>true,
|
27
|
+
'direction'=>false,
|
28
|
+
'level'=>false,
|
29
|
+
'id'=>false,
|
30
|
+
'str'=>true,
|
31
|
+
}
|
32
|
+
|
33
|
+
default_lengths = {
|
34
|
+
'index'=>7,
|
35
|
+
'author'=>13,
|
36
|
+
'timestamp'=>24,
|
37
|
+
'ip'=>22,
|
38
|
+
'port'=>5,
|
39
|
+
'site_id'=>19,
|
40
|
+
'component_id'=>19,
|
41
|
+
'direction'=>4,
|
42
|
+
'level'=>7,
|
43
|
+
'id'=>4,
|
26
44
|
}
|
45
|
+
|
27
46
|
if settings
|
28
47
|
@settings = defaults.merge settings
|
29
48
|
else
|
30
49
|
@settings = defaults
|
31
50
|
end
|
32
51
|
|
33
|
-
|
52
|
+
# copy default length for items that are set to true
|
53
|
+
@settings = @settings.map do |key,value|
|
54
|
+
if value == true && default_lengths[key]
|
55
|
+
[ key, default_lengths[key] ]
|
56
|
+
else
|
57
|
+
[ key, value ]
|
58
|
+
end
|
59
|
+
end.to_h
|
34
60
|
|
61
|
+
@muted = {}
|
35
62
|
setup_output_destination
|
36
63
|
end
|
37
64
|
|
@@ -138,45 +165,39 @@ module RSMP
|
|
138
165
|
end
|
139
166
|
log.join("\n")
|
140
167
|
end
|
141
|
-
|
142
|
-
def build_output item
|
143
|
-
parts = []
|
144
|
-
parts << "#{@settings['prefix']} " if @settings['prefix']
|
145
|
-
parts << item[:index].to_s.ljust(7) if @settings["index"] == true
|
146
|
-
parts << item[:author].to_s.ljust(13) if @settings["author"] == true
|
147
|
-
parts << Clock.to_s(item[:timestamp]).ljust(24) unless @settings["timestamp"] == false
|
148
|
-
parts << item[:ip].to_s.ljust(22) unless @settings["ip"] == false
|
149
|
-
parts << item[:port].to_s.ljust(8) unless @settings["port"] == false
|
150
|
-
parts << item[:site_id].to_s.ljust(13) unless @settings["site_id"] == false
|
151
|
-
parts << item[:component_id].to_s.ljust(18) unless @settings["component"] == false
|
152
|
-
|
153
|
-
directions = {in:"-->",out:"<--"}
|
154
|
-
parts << directions[item[:direction]].to_s.ljust(4) unless @settings["direction"] == false
|
155
|
-
|
156
|
-
parts << item[:level].to_s.capitalize.ljust(7) unless @settings["level"] == false
|
157
168
|
|
169
|
+
def build_part parts, item, key, &block
|
170
|
+
skey = key.to_s
|
171
|
+
return unless @settings[skey]
|
158
172
|
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
parts << item[:str].to_s.strip unless @settings["text"] == false
|
168
|
-
parts << item[:message].json unless @settings["json"] == false || item[:message] == nil
|
169
|
-
|
170
|
-
if item[:exception]
|
171
|
-
parts << "#{item[:exception].class.to_s}\n"
|
172
|
-
parts << item[:exception].backtrace.join("\n")
|
173
|
-
end
|
174
|
-
|
175
|
-
parts.map do |s|
|
176
|
-
next '-'.ljust(s.length) if s !~ /\S/ # replace the first char with a dash if string is all whitespace
|
177
|
-
s
|
178
|
-
end.join(' ').rstrip
|
173
|
+
part = item[key]
|
174
|
+
part = yield part if block
|
175
|
+
part = part.to_s
|
176
|
+
part = part.ljust @settings[skey] if @settings[skey].is_a?(Integer)
|
177
|
+
|
178
|
+
# replace the first char with a dash if string is all whitespace
|
179
|
+
part = @settings['tabs'].ljust(part.length) if @settings['tabs'] && part !~ /\S/
|
180
|
+
parts << part
|
179
181
|
end
|
180
182
|
|
183
|
+
def build_output item
|
184
|
+
parts = []
|
185
|
+
build_part( parts, item, :prefix ) { @settings['prefix'] if @settings['prefix'] != false}
|
186
|
+
build_part( parts, item, :index )
|
187
|
+
build_part( parts, item, :author )
|
188
|
+
build_part( parts, item, :timestamp ) { |part| Clock.to_s part }
|
189
|
+
build_part( parts, item, :ip )
|
190
|
+
build_part( parts, item, :port )
|
191
|
+
build_part( parts, item, :site_id )
|
192
|
+
build_part( parts, item, :component_id )
|
193
|
+
build_part( parts, item, :direction ) { |part| {in:"-->",out:"<--"}[part] }
|
194
|
+
build_part( parts, item, :level ) { |part| part.capitalize }
|
195
|
+
build_part( parts, item, :id ) { Logger.shorten_message_id(item[:message].m_id,4) if item[:message] }
|
196
|
+
build_part( parts, item, :str )
|
197
|
+
build_part( parts, item, :json ) { item[:message].json if item[:message] }
|
198
|
+
build_part( parts, item, :exception ) { |e| [e.class,e.backtrace].flatten.join("\n") }
|
199
|
+
|
200
|
+
parts.join(' ').chomp(@settings['tabs']).rstrip
|
201
|
+
end
|
181
202
|
end
|
182
|
-
end
|
203
|
+
end
|
data/lib/rsmp/version.rb
CHANGED