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
data/lib/pantheios/api.rb CHANGED
@@ -1,16 +1,17 @@
1
-
1
+ # frozen_string_literal: true
2
2
  # ######################################################################## #
3
3
  # File: lib/pantheios/api.rb
4
4
  #
5
5
  # Purpose: The Pantheios.Ruby API (::Pantheios::API)
6
6
  #
7
7
  # Created: 2nd April 2011
8
- # Updated: 4th June 2020
8
+ # Updated: 28th August 2026
9
9
  #
10
- # Home: http://github.com/synesissoftware/Pantheios-Ruby
10
+ # Home: https://github.com/synesissoftware/Pantheios.Ruby
11
11
  #
12
12
  # Author: Matthew Wilson
13
13
  #
14
+ # Copyright (c) 2019-2026, Matthew Wilson and Synesis Information Systems
14
15
  # Copyright (c) 2011-2019, Matthew Wilson and Synesis Software
15
16
  # All rights reserved.
16
17
  #
@@ -77,219 +78,219 @@ module Pantheios
77
78
  # - prefix
78
79
  module API
79
80
 
80
- # Logs an arbitrary set of parameters at the given severity level
81
- def log severity, *args, &block
81
+ # Logs an arbitrary set of parameters at the given severity level
82
+ def log severity, *args, &block
82
83
 
83
- return nil unless severity_logged? severity
84
+ return nil unless severity_logged? severity
84
85
 
85
- log_or_trace_with_block_ 1, severity, args, &block
86
- end
86
+ log_or_trace_with_block_ 1, severity, args, &block
87
+ end
87
88
 
88
- # Logs an array of parameters at the given severity level
89
- def log_v severity, argv, &block
89
+ # Logs an array of parameters at the given severity level
90
+ def log_v severity, argv, &block
90
91
 
91
- return nil unless severity_logged? severity
92
+ return nil unless severity_logged? severity
92
93
 
93
- log_or_trace_with_block_ 1, severity, argv, &block
94
- end
94
+ log_or_trace_with_block_ 1, severity, argv, &block
95
+ end
95
96
 
96
- # Logs an arbitrary set of parameters at the Trace (:trace) level
97
- def trace *args, &block
97
+ # Logs an arbitrary set of parameters at the Trace (:trace) level
98
+ def trace *args, &block
98
99
 
99
- return nil unless tracing?
100
+ return nil unless tracing?
100
101
 
101
- trace_with_block_ 1, args, &block
102
- end
102
+ trace_with_block_ 1, args, &block
103
+ end
103
104
 
104
- # Logs an array of parameters at the Trace (:trace) level
105
- def trace_v argv, &block
105
+ # Logs an array of parameters at the Trace (:trace) level
106
+ def trace_v argv, &block
106
107
 
107
- return nil unless tracing?
108
+ return nil unless tracing?
108
109
 
109
- trace_with_block_ 1, argv, &block
110
- end
110
+ trace_with_block_ 1, argv, &block
111
+ end
111
112
 
112
- if Util::VersionUtil.version_compare(RUBY_VERSION, [ 2, 1 ]) >= 0
113
+ if Util::VersionUtil.version_compare(RUBY_VERSION, [ 2, 1 ]) >= 0
113
114
 
114
- def trace_blv b, lvars, &block
115
+ def trace_blv b, lvars, &block
115
116
 
116
- return nil unless tracing?
117
+ return nil unless tracing?
117
118
 
118
- ::Pantheios::Core.trace_v_impl(self, 1, ApplicationLayer::ParamNameList[*lvars], :trace, lvars.map { |lv| b.local_variable_get(lv) }, &block)
119
- end
120
- end # RUBY_VERSION
119
+ ::Pantheios::Core.trace_v_impl(self, 1, ApplicationLayer::ParamNameList[*lvars], :trace, lvars.map { |lv| b.local_variable_get(lv) }, &block)
120
+ end
121
+ end # RUBY_VERSION
121
122
 
122
- if Util::VersionUtil.version_compare(RUBY_VERSION, [ 2, 2 ]) >= 0
123
+ if Util::VersionUtil.version_compare(RUBY_VERSION, [ 2, 2 ]) >= 0
123
124
 
124
- def trace_b b, &block
125
+ def trace_b b, &block
125
126
 
126
- return nil unless tracing?
127
+ return nil unless tracing?
127
128
 
128
- ::Pantheios::Core.trace_v_impl(self, 1, ApplicationLayer::ParamNameList[*b.local_variables], :trace, b.local_variables.map { |lv| b.local_variable_get(lv) }, &block)
129
- end
130
- end # RUBY_VERSION
129
+ ::Pantheios::Core.trace_v_impl(self, 1, ApplicationLayer::ParamNameList[*b.local_variables], :trace, b.local_variables.map { |lv| b.local_variable_get(lv) }, &block)
130
+ end
131
+ end # RUBY_VERSION
131
132
 
132
133
 
133
- # Determines whether a given severity is logged
134
- #
135
- # === Signature
136
- #
137
- # * *Parameters:*
138
- # - +severity+:: The severity level, which should be a known log
139
- # severity symbol or an integral equivalent
140
- #
141
- # * *Returns:*
142
- # a +truey+ value if the severity should be logged; a +falsey+ value
143
- # otherwise
144
- def severity_logged? severity
134
+ # Determines whether a given severity is logged
135
+ #
136
+ # === Signature
137
+ #
138
+ # * *Parameters:*
139
+ # - +severity+:: The severity level, which should be a known log
140
+ # severity symbol or an integral equivalent
141
+ #
142
+ # * *Returns:*
143
+ # a +truey+ value if the severity should be logged; a +falsey+ value
144
+ # otherwise
145
+ def severity_logged? severity
145
146
 
146
- ::Pantheios::Core.severity_logged? severity
147
- end
147
+ ::Pantheios::Core.severity_logged? severity
148
+ end
148
149
 
149
- # Determines whether tracing (severity == :trace) is enabled. This is
150
- # used in the trace methods (+trace+, +trace_v+, +trace_blv+, +trace_b+)
151
- # and therefore it may be overridden independently of +severity_logged?+
152
- def tracing?
150
+ # Determines whether tracing (severity == :trace) is enabled. This is
151
+ # used in the trace methods (+trace+, +trace_v+, +trace_blv+, +trace_b+)
152
+ # and therefore it may be overridden independently of +severity_logged?+
153
+ def tracing?
153
154
 
154
- severity_logged? :trace
155
- end
155
+ severity_logged? :trace
156
+ end
156
157
 
157
158
 
158
159
 
159
- # Defines the ordered list of log-statement elements
160
- #
161
- # === Elements
162
- #
163
- # Elements can be one of:
164
- # - +:process_name+
165
- # - +:process_id+
166
- # - +:severity+
167
- # - +:thread_id+
168
- # - +:timestamp+
169
- #
170
- # This is called from +prefix+
171
- def prefix_elements
160
+ # Defines the ordered list of log-statement elements
161
+ #
162
+ # === Elements
163
+ #
164
+ # Elements can be one of:
165
+ # - +:process_name+
166
+ # - +:process_id+
167
+ # - +:severity+
168
+ # - +:thread_id+
169
+ # - +:timestamp+
170
+ #
171
+ # This is called from +prefix+
172
+ def prefix_elements
172
173
 
173
- [ :process_name, :thread_id, :timestamp, :severity ]
174
- end
174
+ [ :process_name, :thread_id, :timestamp, :severity ]
175
+ end
175
176
 
176
- # Obtains the process id
177
- #
178
- # Unless overridden, returns the value provided by
179
- # +::Pantheios::Core::process_id+
180
- def process_id
177
+ # Obtains the process id
178
+ #
179
+ # Unless overridden, returns the value provided by
180
+ # +::Pantheios::Core::process_id+
181
+ def process_id
181
182
 
182
- ::Pantheios::Core.process_id
183
- end
183
+ ::Pantheios::Core.process_id
184
+ end
184
185
 
185
- # Obtains the program name
186
- #
187
- # Unless overridden, returns the value provided by
188
- # +::Pantheios::Core::process_name+
189
- def process_name
186
+ # Obtains the program name
187
+ #
188
+ # Unless overridden, returns the value provided by
189
+ # +::Pantheios::Core::process_name+
190
+ def process_name
190
191
 
191
- ::Pantheios::Core.process_name
192
- end
192
+ ::Pantheios::Core.process_name
193
+ end
193
194
 
194
- # Obtains the string corresponding to the severity
195
- #
196
- # Unless overridden, returns the value provided by
197
- # +::Pantheios::Core::severity_string+
198
- def severity_string severity
195
+ # Obtains the string corresponding to the severity
196
+ #
197
+ # Unless overridden, returns the value provided by
198
+ # +::Pantheios::Core::severity_string+
199
+ def severity_string severity
199
200
 
200
- ::Pantheios::Core.severity_string severity
201
- end
201
+ ::Pantheios::Core.severity_string severity
202
+ end
202
203
 
203
- # Obtains the thread id
204
- #
205
- # Unless overridden, returns the value provided by
206
- # +::Pantheios::Core::thread_id+
207
- def thread_id
204
+ # Obtains the thread id
205
+ #
206
+ # Unless overridden, returns the value provided by
207
+ # +::Pantheios::Core::thread_id+
208
+ def thread_id
208
209
 
209
- ::Pantheios::Core.thread_id
210
- end
210
+ ::Pantheios::Core.thread_id
211
+ end
211
212
 
212
- # Obtains a string-form of the timestamp
213
- #
214
- # Unless overridden, returns the value provided by
215
- # +::Pantheios::Core::timestamp+
216
- def timestamp t
213
+ # Obtains a string-form of the timestamp
214
+ #
215
+ # Unless overridden, returns the value provided by
216
+ # +::Pantheios::Core::timestamp+
217
+ def timestamp t
217
218
 
218
- ::Pantheios::Core.timestamp t, nil
219
- end
219
+ ::Pantheios::Core.timestamp t, nil
220
+ end
220
221
 
221
- # Assembles the prefix according to +prefix_elements+ into an array of
222
- # parts
223
- #
224
- # * *Parameters:*
225
- # - +t+ [ Date, Time, DateTime ] The timestamp of the log entry
226
- # - +severity+ The severity
227
- def prefix_parts t, severity
222
+ # Assembles the prefix according to +prefix_elements+ into an array of
223
+ # parts
224
+ #
225
+ # * *Parameters:*
226
+ # - +t+ [ Date, Time, DateTime ] The timestamp of the log entry
227
+ # - +severity+ The severity
228
+ def prefix_parts t, severity
228
229
 
229
- prefix_elements.map do |el|
230
+ prefix_elements.map do |el|
230
231
 
231
- case el
232
- when :program_name, :process_name
232
+ case el
233
+ when :program_name, :process_name
233
234
 
234
- process_name
235
- when :process_id
235
+ process_name
236
+ when :process_id
236
237
 
237
- process_id
238
- when :severity
238
+ process_id
239
+ when :severity
239
240
 
240
- severity_string severity
241
- when :thread_id
241
+ severity_string severity
242
+ when :thread_id
242
243
 
243
- thread_id
244
- when :timestamp
244
+ thread_id
245
+ when :timestamp
245
246
 
246
- timestamp t
247
- else
247
+ timestamp t
248
+ else
248
249
 
249
- s = ::Symbol === el ? ":#{el}" : el.to_s
250
+ s = ::Symbol === el ? ":#{el}" : el.to_s
250
251
 
251
- warn "ignoring unrecognised prefix_element '#{s}'"
252
+ warn "ignoring unrecognised prefix_element '#{s}'"
252
253
 
253
- nil
254
- end
255
- end
256
- end
254
+ nil
255
+ end
256
+ end
257
+ end
257
258
 
258
- # Assembles the +prefix_parts+ into a string
259
- #
260
- # * *Parameters:*
261
- # - +t+ [ Date, Time, DateTime ] The timestamp of the log entry
262
- # - +severity+ The severity
263
- def prefix t, severity
259
+ # Assembles the +prefix_parts+ into a string
260
+ #
261
+ # * *Parameters:*
262
+ # - +t+ [ Date, Time, DateTime ] The timestamp of the log entry
263
+ # - +severity+ The severity
264
+ def prefix t, severity
264
265
 
265
- prefix_parts(t, severity).join(', ')
266
- end
266
+ prefix_parts(t, severity).join(', ')
267
+ end
267
268
 
268
- # @!visibility private
269
- def self.included receiver # :nodoc:
269
+ # @!visibility private
270
+ def self.included receiver # :nodoc:
270
271
 
271
- receiver.extend self
272
+ receiver.extend self
272
273
 
273
- ::Pantheios::Core.register_include self, receiver
274
- end
274
+ ::Pantheios::Core.register_include self, receiver
275
+ end
275
276
 
276
- private
277
+ private
277
278
 
278
- # Private implementation method that should not need to be overridden
279
- def log_or_trace_with_block_ call_depth, severity, argv, &block
279
+ # Private implementation method that should not need to be overridden
280
+ def log_or_trace_with_block_ call_depth, severity, argv, &block
280
281
 
281
- if :trace == severity
282
+ if :trace == severity
282
283
 
283
- return ::Pantheios::Core.trace_v_impl self, 1 + call_depth, nil, severity, argv, &block
284
- end
284
+ return ::Pantheios::Core.trace_v_impl self, 1 + call_depth, nil, severity, argv, &block
285
+ end
285
286
 
286
- ::Pantheios::Core.log_v_impl self, severity, argv, &block
287
- end
287
+ ::Pantheios::Core.log_v_impl self, severity, argv, &block
288
+ end
288
289
 
289
- def trace_with_block_ call_depth, argv, &block
290
+ def trace_with_block_ call_depth, argv, &block
290
291
 
291
- return ::Pantheios::Core.trace_v_impl self, 1 + call_depth, nil, :trace, argv, &block
292
- end
292
+ return ::Pantheios::Core.trace_v_impl self, 1 + call_depth, nil, :trace, argv, &block
293
+ end
293
294
 
294
295
  end # module API
295
296
  end # module Pantheios
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  module Pantheios
3
4
  module ApplicationLayer