pantheios-ruby 0.22.0.2 → 0.22.3

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.
Files changed (61) hide show
  1. checksums.yaml +5 -5
  2. data/AUTHORS.md +21 -0
  3. data/CHANGES.md +337 -0
  4. data/CONTRIBUTING.md +36 -0
  5. data/EXAMPLES.md +11 -0
  6. data/FAQ.md +28 -0
  7. data/INSTALL.md +43 -0
  8. data/LICENSE +21 -20
  9. data/NEWS.md +65 -0
  10. data/README.md +134 -2
  11. data/Rakefile +21 -0
  12. data/SECURITY.md +23 -0
  13. data/TODO.md +29 -0
  14. data/examples/coloured_console_log_service.rb +1 -1
  15. data/examples/multiple_modules.md +1 -1
  16. data/examples/multiple_modules.rb +36 -36
  17. data/examples/simple_logging.md +1 -1
  18. data/examples/simple_logging.rb +1 -1
  19. data/examples/threshold_front_end.rb +1 -1
  20. data/lib/pantheios/api.rb +156 -155
  21. data/lib/pantheios/application_layer/param_name_list.rb +1 -0
  22. data/lib/pantheios/application_layer/stock_severity_levels.rb +110 -111
  23. data/lib/pantheios/application_layer.rb +6 -5
  24. data/lib/pantheios/core.rb +416 -415
  25. data/lib/pantheios/front_ends/threshold_front_end.rb +81 -81
  26. data/lib/pantheios/globals.rb +45 -45
  27. data/lib/pantheios/services/coloured_console_log_service.rb +96 -96
  28. data/lib/pantheios/services/common/console.rb +58 -57
  29. data/lib/pantheios/services/multiplexing_log_service.rb +151 -150
  30. data/lib/pantheios/services/null_log_service.rb +11 -11
  31. data/lib/pantheios/services/simple_console_log_service.rb +20 -20
  32. data/lib/pantheios/services/simple_file_log_service.rb +112 -113
  33. data/lib/pantheios/services/standard_log_service_adapter.rb +119 -119
  34. data/lib/pantheios/services.rb +1 -0
  35. data/lib/pantheios/util/process_util.rb +25 -24
  36. data/lib/pantheios/util/reflection_util.rb +14 -13
  37. data/lib/pantheios/util/thread_util.rb +50 -49
  38. data/lib/pantheios/util/version_util.rb +34 -33
  39. data/lib/pantheios/util.rb +1 -0
  40. data/lib/pantheios/version.rb +19 -19
  41. data/lib/pantheios.rb +12 -12
  42. data/test/performance/test_perf_simple_statements.rb +58 -58
  43. data/test/performance/test_perf_trace_variants.rb +43 -57
  44. data/test/scratch/log_rolling_by_period_daily.rb +3 -3
  45. data/test/scratch/log_rolling_by_size_and_depth.rb +3 -3
  46. data/test/scratch/log_using_blocks.rb +12 -12
  47. data/test/scratch/multiplexing_log_service.rb +32 -32
  48. data/test/unit/application_layer/tc_param_name_list.rb +13 -13
  49. data/test/unit/application_layer/tc_stock_severity_levels.rb +102 -102
  50. data/test/unit/core/tc_core_1.rb +24 -24
  51. data/test/unit/front_ends/tc_threshold_front_end.rb +65 -65
  52. data/test/unit/services/tc_multiplexing_log_service.rb +79 -79
  53. data/test/unit/services/tc_null_log_service.rb +42 -42
  54. data/test/unit/services/tc_simple_console_log_service.rb +70 -70
  55. data/test/unit/services/tc_simple_file_log_service.rb +146 -146
  56. data/test/unit/services/tc_standard_log_service_adapter.rb +94 -96
  57. data/test/unit/util/tc_process_util.rb +6 -6
  58. data/test/unit/util/tc_reflection_util.rb +20 -20
  59. data/test/unit/util/tc_thread_util.rb +46 -46
  60. data/test/unit/util/tc_version_util.rb +47 -47
  61. metadata +33 -12
@@ -17,236 +17,236 @@ require 'tempfile'
17
17
 
18
18
  class Test_SimpleFileLogservice < Test::Unit::TestCase
19
19
 
20
- include ::Pantheios::Services
20
+ include ::Pantheios::Services
21
21
 
22
- def test_SimpleFileLogService_type_exists
22
+ def test_SimpleFileLogService_type_exists
23
23
 
24
- assert defined? SimpleFileLogService
25
- end
24
+ assert defined? SimpleFileLogService
25
+ end
26
26
 
27
- if defined?(SimpleFileLogService)
27
+ if defined?(SimpleFileLogService)
28
28
 
29
- def self.log_to_StringIO_and_get_output messages, def_sev, def_pref = nil, def_t = nil, **options
29
+ def self.log_to_StringIO_and_get_output messages, def_sev, def_pref = nil, def_t = nil, **options
30
30
 
31
- def_t ||= Time.now
32
- def_pref ||= "[prog, thread, #{def_t}]: "
31
+ def_t ||= Time.now
32
+ def_pref ||= "[prog, thread, #{def_t}]: "
33
33
 
34
- stream = StringIO.new
34
+ stream = StringIO.new
35
35
 
36
- svc = SimpleFileLogService.new stream, **options
36
+ svc = SimpleFileLogService.new stream, **options
37
37
 
38
- messages.each do |message|
38
+ messages.each do |message|
39
39
 
40
- ar = ::Array === message ? message : [ message ]
40
+ ar = ::Array === message ? message : [ message ]
41
41
 
42
- msg = ar[0]
43
- sev = ar[1] || def_sev
44
- pref = ar[2] || def_pref
45
- t = ar[3] || def_t
42
+ msg = ar[0]
43
+ sev = ar[1] || def_sev
44
+ pref = ar[2] || def_pref
45
+ t = ar[3] || def_t
46
46
 
47
- svc.log sev, t, pref, msg
48
- end
47
+ svc.log sev, t, pref, msg
48
+ end
49
49
 
50
- stream.string
51
- end
50
+ stream.string
51
+ end
52
52
 
53
- def self.log_to_Tempfile_and_get_output messages, def_sev, def_pref = nil, def_t = nil, **options
53
+ def self.log_to_Tempfile_and_get_output messages, def_sev, def_pref = nil, def_t = nil, **options
54
54
 
55
- def_t ||= Time.now
56
- def_pref ||= "[prog, thread, #{def_t}]: "
55
+ def_t ||= Time.now
56
+ def_pref ||= "[prog, thread, #{def_t}]: "
57
57
 
58
- tf = Tempfile.new 'Pantheios.Ruby.Tempfile'
58
+ tf = Tempfile.new 'Pantheios.Ruby.Tempfile'
59
59
 
60
- begin
60
+ begin
61
61
 
62
- svc = SimpleFileLogService.new tf, **options
62
+ svc = SimpleFileLogService.new tf, **options
63
63
 
64
- messages.each do |message|
64
+ messages.each do |message|
65
65
 
66
- ar = ::Array === message ? message : [ message ]
66
+ ar = ::Array === message ? message : [ message ]
67
67
 
68
- msg = ar[0]
69
- sev = ar[1] || def_sev
70
- pref = ar[2] || def_pref
71
- t = ar[3] || def_t
68
+ msg = ar[0]
69
+ sev = ar[1] || def_sev
70
+ pref = ar[2] || def_pref
71
+ t = ar[3] || def_t
72
72
 
73
- svc.log sev, t, pref, msg
74
- end
73
+ svc.log sev, t, pref, msg
74
+ end
75
75
 
76
- tf.rewind
76
+ tf.rewind
77
77
 
78
- return tf.read
79
- ensure
78
+ return tf.read
79
+ ensure
80
80
 
81
- tf.close
82
- tf.unlink
83
- end
84
- end
81
+ tf.close
82
+ tf.unlink
83
+ end
84
+ end
85
85
 
86
- def self.log_to_Tempfile_path_and_get_output messages, def_sev, def_pref = nil, def_t = nil, **options
86
+ def self.log_to_Tempfile_path_and_get_output messages, def_sev, def_pref = nil, def_t = nil, **options
87
87
 
88
- def_t ||= Time.now
89
- def_pref ||= "[prog, thread, #{def_t}]: "
88
+ def_t ||= Time.now
89
+ def_pref ||= "[prog, thread, #{def_t}]: "
90
90
 
91
- tf = Tempfile.new 'Pantheios.Ruby.Tempfile'
91
+ tf = Tempfile.new 'Pantheios.Ruby.Tempfile'
92
92
 
93
- begin
93
+ begin
94
94
 
95
- svc = SimpleFileLogService.new tf.path, **options
95
+ svc = SimpleFileLogService.new tf.path, **options
96
96
 
97
- messages.each do |message|
97
+ messages.each do |message|
98
98
 
99
- ar = ::Array === message ? message : [ message ]
99
+ ar = ::Array === message ? message : [ message ]
100
100
 
101
- msg = ar[0]
102
- sev = ar[1] || def_sev
103
- pref = ar[2] || def_pref
104
- t = ar[3] || def_t
101
+ msg = ar[0]
102
+ sev = ar[1] || def_sev
103
+ pref = ar[2] || def_pref
104
+ t = ar[3] || def_t
105
105
 
106
- svc.log sev, t, pref, msg
107
- end
106
+ svc.log sev, t, pref, msg
107
+ end
108
108
 
109
- tf.rewind
109
+ tf.rewind
110
110
 
111
- return tf.read
112
- ensure
111
+ return tf.read
112
+ ensure
113
113
 
114
- tf.close
115
- tf.unlink
116
- end
117
- end
114
+ tf.close
115
+ tf.unlink
116
+ end
117
+ end
118
118
 
119
- def test_SimpleFileLogService_type_is_a_class
119
+ def test_SimpleFileLogService_type_is_a_class
120
120
 
121
- assert_kind_of(::Class, SimpleFileLogService)
122
- end
121
+ assert_kind_of(::Class, SimpleFileLogService)
122
+ end
123
123
 
124
- def test_SimpleFileLogService_type_has_expected_instance_methods
124
+ def test_SimpleFileLogService_type_has_expected_instance_methods
125
125
 
126
- assert_type_has_instance_methods SimpleFileLogService, [ :severity_logged?, :log ]
127
- end
126
+ assert_type_has_instance_methods SimpleFileLogService, [ :severity_logged?, :log ]
127
+ end
128
128
 
129
- def test_ctor_failures_with_invalid_log_file_or_path
129
+ def test_ctor_failures_with_invalid_log_file_or_path
130
130
 
131
- assert_raise_with_message(::ArgumentError, /log_file_or_path.*not.*nil/) { SimpleFileLogService.new nil }
131
+ assert_raise_with_message(::ArgumentError, /log_file_or_path.*not.*nil/) { SimpleFileLogService.new nil }
132
132
 
133
- assert_raise_with_message(::TypeError, [ /log_file_or_path.*must be/, /::File/, /::IO/, /::String/, /::StringIO/ ]) { SimpleFileLogService.new // }
134
- end
133
+ assert_raise_with_message(::TypeError, [ /log_file_or_path.*must be/, /::File/, /::IO/, /::String/, /::StringIO/ ]) { SimpleFileLogService.new(//) }
134
+ end
135
135
 
136
- def test_ctor_failures_with_invalid_options
136
+ def test_ctor_failures_with_invalid_options
137
137
 
138
- assert_raise_with_message(::ArgumentError, /:roll_depth.*non.*negative.*integer/) { SimpleFileLogService.new '/dev/null', roll_depth: true }
139
- assert_raise_with_message(::ArgumentError, /:roll_depth.*non.*negative.*integer/) { SimpleFileLogService.new '/dev/null', roll_depth: -1 }
138
+ assert_raise_with_message(::ArgumentError, /:roll_depth.*non.*negative.*integer/) { SimpleFileLogService.new '/dev/null', roll_depth: true }
139
+ assert_raise_with_message(::ArgumentError, /:roll_depth.*non.*negative.*integer/) { SimpleFileLogService.new '/dev/null', roll_depth: -1 }
140
140
 
141
- assert_raise_with_message(::ArgumentError, /:roll_size.*non.*negative.*integer/) { SimpleFileLogService.new '/dev/null', roll_size: true }
142
- assert_raise_with_message(::ArgumentError, /:roll_size.*non.*negative.*integer/) { SimpleFileLogService.new '/dev/null', roll_size: -1 }
143
- end
141
+ assert_raise_with_message(::ArgumentError, /:roll_size.*non.*negative.*integer/) { SimpleFileLogService.new '/dev/null', roll_size: true }
142
+ assert_raise_with_message(::ArgumentError, /:roll_size.*non.*negative.*integer/) { SimpleFileLogService.new '/dev/null', roll_size: -1 }
143
+ end
144
144
 
145
- def test_severity_logged_false_with_large_range_of_integers
145
+ def test_severity_logged_false_with_large_range_of_integers
146
146
 
147
- output = StringIO.new
147
+ output = StringIO.new
148
148
 
149
- svc = SimpleFileLogService.new output
149
+ svc = SimpleFileLogService.new output
150
150
 
151
- (-10000 .. 10000).each do |sev|
151
+ (-10000 .. 10000).each do |sev|
152
152
 
153
- assert_true(svc.severity_logged?(sev), "severity '#{sev}' (#{sev.class}) was not logged")
154
- end
155
- end
153
+ assert_true(svc.severity_logged?(sev), "severity '#{sev}' (#{sev.class}) was not logged")
154
+ end
155
+ end
156
156
 
157
- def test_simple_logging_with_StringIO_1
157
+ def test_simple_logging_with_StringIO_1
158
158
 
159
- message = 'msg'
159
+ message = 'msg'
160
160
 
161
- output = self.class.log_to_StringIO_and_get_output [ message ], :notice, nil, nil
161
+ output = self.class.log_to_StringIO_and_get_output [ message ], :notice, nil, nil
162
162
 
163
- lines = output.split /\n/
163
+ lines = output.split(/\n/)
164
164
 
165
- assert_not_empty lines
166
- assert_equal 1, lines.size
167
- assert_match /msg$/, lines[0]
168
- end
165
+ assert_not_empty lines
166
+ assert_equal 1, lines.size
167
+ assert_match(/msg$/, lines[0])
168
+ end
169
169
 
170
- def test_simple_logging_with_StringIO_2
170
+ def test_simple_logging_with_StringIO_2
171
171
 
172
- msgs = [
172
+ msgs = [
173
173
 
174
- [ 'msg-1' ],
175
- [ 'msg-2' ],
176
- ]
174
+ [ 'msg-1' ],
175
+ [ 'msg-2' ],
176
+ ]
177
177
 
178
- output = self.class.log_to_StringIO_and_get_output msgs, :notice, nil, nil
178
+ output = self.class.log_to_StringIO_and_get_output msgs, :notice, nil, nil
179
179
 
180
- lines = output.split /\n/
180
+ lines = output.split(/\n/)
181
181
 
182
- assert_not_empty lines
183
- assert_equal 2, lines.size
184
- assert_match /msg-1$/, lines[0]
185
- assert_match /msg-2$/, lines[1]
186
- end
182
+ assert_not_empty lines
183
+ assert_equal 2, lines.size
184
+ assert_match(/msg-1$/, lines[0])
185
+ assert_match(/msg-2$/, lines[1])
186
+ end
187
187
 
188
- def test_simple_logging_with_Tempfile_1
188
+ def test_simple_logging_with_Tempfile_1
189
189
 
190
- message = 'msg'
190
+ message = 'msg'
191
191
 
192
- output = self.class.log_to_Tempfile_and_get_output [ message ], :notice, nil, nil
192
+ output = self.class.log_to_Tempfile_and_get_output [ message ], :notice, nil, nil
193
193
 
194
- lines = output.split /\n/
194
+ lines = output.split(/\n/)
195
195
 
196
- assert_not_empty lines
197
- assert_equal 1, lines.size
198
- assert_match /msg$/, lines[0]
199
- end
196
+ assert_not_empty lines
197
+ assert_equal 1, lines.size
198
+ assert_match(/msg$/, lines[0])
199
+ end
200
200
 
201
- def test_simple_logging_with_Tempfile_2
201
+ def test_simple_logging_with_Tempfile_2
202
202
 
203
- msgs = [
203
+ msgs = [
204
204
 
205
- [ 'msg-1' ],
206
- [ 'msg-2' ],
207
- ]
205
+ [ 'msg-1' ],
206
+ [ 'msg-2' ],
207
+ ]
208
208
 
209
- output = self.class.log_to_Tempfile_and_get_output msgs, :notice, nil, nil
209
+ output = self.class.log_to_Tempfile_and_get_output msgs, :notice, nil, nil
210
210
 
211
- lines = output.split /\n/
211
+ lines = output.split(/\n/)
212
212
 
213
- assert_not_empty lines
214
- assert_equal 2, lines.size
215
- assert_match /msg-1$/, lines[0]
216
- assert_match /msg-2$/, lines[1]
217
- end
213
+ assert_not_empty lines
214
+ assert_equal 2, lines.size
215
+ assert_match(/msg-1$/, lines[0])
216
+ assert_match(/msg-2$/, lines[1])
217
+ end
218
218
 
219
- def test_simple_logging_with_Tempfile_path_1
219
+ def test_simple_logging_with_Tempfile_path_1
220
220
 
221
- message = 'msg'
221
+ message = 'msg'
222
222
 
223
- output = self.class.log_to_Tempfile_path_and_get_output [ message ], :notice, nil, nil
223
+ output = self.class.log_to_Tempfile_path_and_get_output [ message ], :notice, nil, nil
224
224
 
225
- lines = output.split /\n/
225
+ lines = output.split(/\n/)
226
226
 
227
- assert_not_empty lines
228
- assert_equal 1, lines.size
229
- assert_match /msg$/, lines[0]
230
- end
227
+ assert_not_empty lines
228
+ assert_equal 1, lines.size
229
+ assert_match(/msg$/, lines[0])
230
+ end
231
231
 
232
- def test_simple_logging_with_Tempfile_path_2
232
+ def test_simple_logging_with_Tempfile_path_2
233
233
 
234
- msgs = [
234
+ msgs = [
235
235
 
236
- [ 'msg-1' ],
237
- [ 'msg-2' ],
238
- ]
236
+ [ 'msg-1' ],
237
+ [ 'msg-2' ],
238
+ ]
239
239
 
240
- output = self.class.log_to_Tempfile_path_and_get_output msgs, :notice, nil, nil
240
+ output = self.class.log_to_Tempfile_path_and_get_output msgs, :notice, nil, nil
241
241
 
242
- lines = output.split /\n/
242
+ lines = output.split(/\n/)
243
243
 
244
- assert_not_empty lines
245
- assert_equal 2, lines.size
246
- assert_match /msg-1$/, lines[0]
247
- assert_match /msg-2$/, lines[1]
248
- end
249
- end
244
+ assert_not_empty lines
245
+ assert_equal 2, lines.size
246
+ assert_match(/msg-1$/, lines[0])
247
+ assert_match(/msg-2$/, lines[1])
248
+ end
249
+ end
250
250
  end
251
251
 
252
252
 
@@ -18,151 +18,149 @@ require 'stringio'
18
18
 
19
19
  class Test_StandardLogservice < Test::Unit::TestCase
20
20
 
21
- include ::Pantheios::Services
21
+ include ::Pantheios::Services
22
22
 
23
- STOCK_SEVERITY_LEVEL_VALUES = ::Pantheios::ApplicationLayer::StockSeverityLevels::STOCK_SEVERITY_LEVEL_VALUES
23
+ STOCK_SEVERITY_LEVEL_VALUES = ::Pantheios::ApplicationLayer::StockSeverityLevels::STOCK_SEVERITY_LEVEL_VALUES
24
24
 
25
- def test_StandardLogServiceAdapter_type_exists
25
+ def test_StandardLogServiceAdapter_type_exists
26
26
 
27
- assert defined? StandardLogServiceAdapter
28
- end
27
+ assert defined? StandardLogServiceAdapter
28
+ end
29
29
 
30
- if defined?(StandardLogServiceAdapter)
30
+ if defined?(StandardLogServiceAdapter)
31
31
 
32
- def test_StandardLogServiceAdapter_type_is_a_class
32
+ def test_StandardLogServiceAdapter_type_is_a_class
33
33
 
34
- assert_kind_of(::Class, StandardLogServiceAdapter)
35
- end
34
+ assert_kind_of(::Class, StandardLogServiceAdapter)
35
+ end
36
36
 
37
- def test_StandardLogServiceAdapter_type_has_expected_instance_methods
37
+ def test_StandardLogServiceAdapter_type_has_expected_instance_methods
38
38
 
39
- assert_type_has_instance_methods StandardLogServiceAdapter, [ :severity_logged?, :log ]
40
- end
39
+ assert_type_has_instance_methods StandardLogServiceAdapter, [ :severity_logged?, :log ]
40
+ end
41
41
 
42
- def test_severity_logged
42
+ def test_severity_logged
43
43
 
44
- logdev = StringIO.new
45
- logger = ::Logger.new logdev
44
+ logdev = StringIO.new
45
+ logger = ::Logger.new logdev
46
46
 
47
- svc = StandardLogServiceAdapter.new logger
47
+ svc = StandardLogServiceAdapter.new logger
48
48
 
49
- logger.level = ::Logger::WARN
49
+ logger.level = ::Logger::WARN
50
50
 
51
- assert_false svc.severity_logged?(:debug4)
52
- assert_false svc.severity_logged?(:debug3)
53
- assert_false svc.severity_logged?(:debug2)
54
- assert_false svc.severity_logged?(:debug1)
55
- assert_false svc.severity_logged?(:debug0)
56
- assert_false svc.severity_logged?(:informational)
57
- assert_false svc.severity_logged?(:notice)
58
- assert_true svc.severity_logged?(:warning)
59
- assert_true svc.severity_logged?(:failure)
60
- assert_true svc.severity_logged?(:critical)
61
- assert_true svc.severity_logged?(:alert)
62
- assert_true svc.severity_logged?(:violation)
51
+ assert_false svc.severity_logged?(:debug4)
52
+ assert_false svc.severity_logged?(:debug3)
53
+ assert_false svc.severity_logged?(:debug2)
54
+ assert_false svc.severity_logged?(:debug1)
55
+ assert_false svc.severity_logged?(:debug0)
56
+ assert_false svc.severity_logged?(:informational)
57
+ assert_false svc.severity_logged?(:notice)
58
+ assert_true svc.severity_logged?(:warning)
59
+ assert_true svc.severity_logged?(:failure)
60
+ assert_true svc.severity_logged?(:critical)
61
+ assert_true svc.severity_logged?(:alert)
62
+ assert_true svc.severity_logged?(:violation)
63
63
 
64
- assert_true svc.severity_logged?(nil)
64
+ assert_true svc.severity_logged?(nil)
65
65
 
66
- assert_false svc.severity_logged?(STOCK_SEVERITY_LEVEL_VALUES[:debug4])
67
- assert_false svc.severity_logged?(STOCK_SEVERITY_LEVEL_VALUES[:debug3])
68
- assert_false svc.severity_logged?(STOCK_SEVERITY_LEVEL_VALUES[:debug2])
69
- assert_false svc.severity_logged?(STOCK_SEVERITY_LEVEL_VALUES[:debug1])
70
- assert_false svc.severity_logged?(STOCK_SEVERITY_LEVEL_VALUES[:debug0])
71
- assert_false svc.severity_logged?(STOCK_SEVERITY_LEVEL_VALUES[:informational])
72
- assert_false svc.severity_logged?(STOCK_SEVERITY_LEVEL_VALUES[:notice])
73
- assert_true svc.severity_logged?(STOCK_SEVERITY_LEVEL_VALUES[:warning])
74
- assert_true svc.severity_logged?(STOCK_SEVERITY_LEVEL_VALUES[:failure])
75
- assert_true svc.severity_logged?(STOCK_SEVERITY_LEVEL_VALUES[:critical])
76
- assert_true svc.severity_logged?(STOCK_SEVERITY_LEVEL_VALUES[:alert])
77
- assert_true svc.severity_logged?(STOCK_SEVERITY_LEVEL_VALUES[:violation])
78
- end
66
+ assert_false svc.severity_logged?(STOCK_SEVERITY_LEVEL_VALUES[:debug4])
67
+ assert_false svc.severity_logged?(STOCK_SEVERITY_LEVEL_VALUES[:debug3])
68
+ assert_false svc.severity_logged?(STOCK_SEVERITY_LEVEL_VALUES[:debug2])
69
+ assert_false svc.severity_logged?(STOCK_SEVERITY_LEVEL_VALUES[:debug1])
70
+ assert_false svc.severity_logged?(STOCK_SEVERITY_LEVEL_VALUES[:debug0])
71
+ assert_false svc.severity_logged?(STOCK_SEVERITY_LEVEL_VALUES[:informational])
72
+ assert_false svc.severity_logged?(STOCK_SEVERITY_LEVEL_VALUES[:notice])
73
+ assert_true svc.severity_logged?(STOCK_SEVERITY_LEVEL_VALUES[:warning])
74
+ assert_true svc.severity_logged?(STOCK_SEVERITY_LEVEL_VALUES[:failure])
75
+ assert_true svc.severity_logged?(STOCK_SEVERITY_LEVEL_VALUES[:critical])
76
+ assert_true svc.severity_logged?(STOCK_SEVERITY_LEVEL_VALUES[:alert])
77
+ assert_true svc.severity_logged?(STOCK_SEVERITY_LEVEL_VALUES[:violation])
78
+ end
79
79
 
80
- def test_selected_log_with_default_format
80
+ def test_selected_log_with_default_format
81
81
 
82
- logdev = StringIO.new
83
- logger = ::Logger.new logdev
82
+ logdev = StringIO.new
83
+ logger = ::Logger.new logdev
84
84
 
85
- svc = StandardLogServiceAdapter.new logger
85
+ svc = StandardLogServiceAdapter.new logger
86
86
 
87
- logger.level = ::Logger::WARN
87
+ logger.level = ::Logger::WARN
88
88
 
89
- t = Time.now
90
- pid = Process.pid
91
- prname = ::Pantheios::Util::ProcessUtil.derive_process_name
89
+ t = Time.now
90
+ prname = ::Pantheios::Util::ProcessUtil.derive_process_name
92
91
 
93
- [ :notice, :warning, :critical ].each do |level|
92
+ [ :notice, :warning, :critical ].each do |level|
94
93
 
95
- svc.log level, t, nil, "a message at #{level}" if svc.severity_logged? level
96
- end
94
+ svc.log level, t, nil, "a message at #{level}" if svc.severity_logged? level
95
+ end
97
96
 
98
- svc.flush if svc.respond_to? :flush
97
+ svc.flush if svc.respond_to? :flush
99
98
 
100
- res = logdev.string.split /\n/
99
+ res = logdev.string.split(/\n/)
101
100
 
102
- assert_equal 2, res.size
101
+ assert_equal 2, res.size
103
102
 
104
- assert_match /W\s*,\s*\[.*##{pid}\s*\]\s*WARN\s*--\s*#{prname}\s*:\s*a message at warning/, res[0]
105
- assert_match /E\s*,\s*\[.*##{pid}\s*\]\s*ERROR\s*--\s*#{prname}\s*:\s*a message at critical/, res[1]
106
- end
103
+ assert_match(/W\s*,\s*\[.*##{Process.pid}\s*\]\s*WARN\s*--\s*#{prname}\s*:\s*a message at warning/, res[0])
104
+ assert_match(/E\s*,\s*\[.*##{Process.pid}\s*\]\s*ERROR\s*--\s*#{prname}\s*:\s*a message at critical/, res[1])
105
+ end
107
106
 
108
- def test_selected_log_with_blank_format
107
+ def test_selected_log_with_blank_format
109
108
 
110
- logdev = StringIO.new
111
- logger = ::Logger.new logdev
109
+ logdev = StringIO.new
110
+ logger = ::Logger.new logdev
112
111
 
113
- svc = StandardLogServiceAdapter.new logger, format: :simple
112
+ svc = StandardLogServiceAdapter.new logger, format: :simple
114
113
 
115
- logger.level = ::Logger::WARN
114
+ logger.level = ::Logger::WARN
116
115
 
117
- t = Time.now
116
+ t = Time.now
118
117
 
119
- [ :notice, :warning, :critical ].each do |level|
118
+ [ :notice, :warning, :critical ].each do |level|
120
119
 
121
- svc.log level, t, nil, "a message at #{level}" if svc.severity_logged? level
122
- end
120
+ svc.log level, t, nil, "a message at #{level}" if svc.severity_logged? level
121
+ end
123
122
 
124
- svc.flush if svc.respond_to? :flush
123
+ svc.flush if svc.respond_to? :flush
125
124
 
126
- res = logdev.string.split /\n/
125
+ res = logdev.string.split(/\n/)
127
126
 
128
- assert_equal 2, res.size
127
+ assert_equal 2, res.size
129
128
 
130
- assert_equal 'a message at warning', res[0]
131
- assert_equal 'a message at critical', res[1]
132
- end
129
+ assert_equal 'a message at warning', res[0]
130
+ assert_equal 'a message at critical', res[1]
131
+ end
133
132
 
134
- def test_selected_log_with_standard_format
133
+ def test_selected_log_with_standard_format
135
134
 
136
- logdev = StringIO.new
137
- logger = ::Logger.new logdev
135
+ logdev = StringIO.new
136
+ logger = ::Logger.new logdev
138
137
 
139
- svc = StandardLogServiceAdapter.new logger, format: :standard
138
+ svc = StandardLogServiceAdapter.new logger, format: :standard
140
139
 
141
- logger.level = ::Logger::WARN
140
+ logger.level = ::Logger::WARN
142
141
 
143
- t = Time.now
144
- pid = Process.pid
145
- tid = Thread.current.object_id
146
- prname = ::Pantheios::Util::ProcessUtil.derive_process_name
147
- ts = t.strftime '%Y-%m-%d %H:%M:%S.%6N'
142
+ t = Time.now
143
+ tid = Thread.current.object_id
144
+ prname = ::Pantheios::Util::ProcessUtil.derive_process_name
145
+ ts = t.strftime '%Y-%m-%d %H:%M:%S.%6N'
148
146
 
149
- [ :notice, :warning, :critical ].each do |level|
147
+ [ :notice, :warning, :critical ].each do |level|
150
148
 
151
- pref = "[#{prname} #{tid} #{ts} #{level}]"
149
+ pref = "[#{prname} #{tid} #{ts} #{level}]"
152
150
 
153
- svc.log level, t, pref, "a message at #{level}" if svc.severity_logged? level
154
- end
151
+ svc.log level, t, pref, "a message at #{level}" if svc.severity_logged? level
152
+ end
155
153
 
156
- svc.flush if svc.respond_to? :flush
154
+ svc.flush if svc.respond_to? :flush
157
155
 
158
- res = logdev.string.split /\n/
156
+ res = logdev.string.split(/\n/)
159
157
 
160
- assert_equal 2, res.size
158
+ assert_equal 2, res.size
161
159
 
162
- assert_match /\s*\[\s*#{prname} #{tid} #{ts} warning\s*\]\s*a message at warning/, res[0]
163
- assert_match /\s*\[\s*#{prname} #{tid} #{ts} critical\s*\]\s*a message at critical/, res[1]
164
- end
165
- end
160
+ assert_match(/\s*\[\s*#{prname} #{tid} #{ts} warning\s*\]\s*a message at warning/, res[0])
161
+ assert_match(/\s*\[\s*#{prname} #{tid} #{ts} critical\s*\]\s*a message at critical/, res[1])
162
+ end
163
+ end
166
164
  end
167
165
 
168
166
 
@@ -10,15 +10,15 @@ require 'test/unit'
10
10
 
11
11
  class Test_ProcessUtil_set_thread_name < Test::Unit::TestCase
12
12
 
13
- PU = ::Pantheios::Util::ProcessUtil
13
+ PU = ::Pantheios::Util::ProcessUtil
14
14
 
15
- def test_derive_process_name
15
+ def test_derive_process_name
16
16
 
17
- assert_equal 'abc', PU.derive_process_name('abc')
17
+ assert_equal 'abc', PU.derive_process_name('abc')
18
18
 
19
- assert_equal 'abc', PU.derive_process_name('abc.rb')
19
+ assert_equal 'abc', PU.derive_process_name('abc.rb')
20
20
 
21
- assert_equal 'abc', PU.derive_process_name('abc.rb')
22
- end
21
+ assert_equal 'abc', PU.derive_process_name('abc.rb')
22
+ end
23
23
  end
24
24