pantheios-ruby 0.22.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 (47) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +26 -0
  3. data/NEWS.md +1 -0
  4. data/TODO.md +5 -2
  5. data/examples/coloured_console_log_service.rb +1 -1
  6. data/examples/multiple_modules.rb +36 -36
  7. data/examples/simple_logging.rb +1 -1
  8. data/examples/threshold_front_end.rb +1 -1
  9. data/lib/pantheios/api.rb +154 -153
  10. data/lib/pantheios/application_layer/stock_severity_levels.rb +108 -108
  11. data/lib/pantheios/application_layer.rb +5 -5
  12. data/lib/pantheios/core.rb +415 -414
  13. data/lib/pantheios/front_ends/threshold_front_end.rb +79 -79
  14. data/lib/pantheios/globals.rb +43 -43
  15. data/lib/pantheios/services/coloured_console_log_service.rb +94 -94
  16. data/lib/pantheios/services/common/console.rb +57 -57
  17. data/lib/pantheios/services/multiplexing_log_service.rb +149 -148
  18. data/lib/pantheios/services/null_log_service.rb +9 -9
  19. data/lib/pantheios/services/simple_console_log_service.rb +18 -18
  20. data/lib/pantheios/services/simple_file_log_service.rb +110 -111
  21. data/lib/pantheios/services/standard_log_service_adapter.rb +117 -117
  22. data/lib/pantheios/util/process_util.rb +24 -24
  23. data/lib/pantheios/util/reflection_util.rb +13 -13
  24. data/lib/pantheios/util/thread_util.rb +49 -49
  25. data/lib/pantheios/util/version_util.rb +33 -33
  26. data/lib/pantheios/version.rb +12 -12
  27. data/lib/pantheios.rb +11 -11
  28. data/test/performance/test_perf_simple_statements.rb +58 -58
  29. data/test/performance/test_perf_trace_variants.rb +43 -57
  30. data/test/scratch/log_rolling_by_period_daily.rb +3 -3
  31. data/test/scratch/log_rolling_by_size_and_depth.rb +3 -3
  32. data/test/scratch/log_using_blocks.rb +12 -12
  33. data/test/scratch/multiplexing_log_service.rb +32 -32
  34. data/test/unit/application_layer/tc_param_name_list.rb +13 -13
  35. data/test/unit/application_layer/tc_stock_severity_levels.rb +102 -102
  36. data/test/unit/core/tc_core_1.rb +24 -24
  37. data/test/unit/front_ends/tc_threshold_front_end.rb +65 -65
  38. data/test/unit/services/tc_multiplexing_log_service.rb +79 -79
  39. data/test/unit/services/tc_null_log_service.rb +42 -42
  40. data/test/unit/services/tc_simple_console_log_service.rb +70 -70
  41. data/test/unit/services/tc_simple_file_log_service.rb +146 -146
  42. data/test/unit/services/tc_standard_log_service_adapter.rb +94 -96
  43. data/test/unit/util/tc_process_util.rb +6 -6
  44. data/test/unit/util/tc_reflection_util.rb +20 -20
  45. data/test/unit/util/tc_thread_util.rb +46 -46
  46. data/test/unit/util/tc_version_util.rb +47 -47
  47. metadata +6 -6
@@ -6,85 +6,85 @@ module Common
6
6
 
7
7
  module Console
8
8
 
9
- module Internal_
9
+ module Internal_
10
10
 
11
- STDERR_ISATTY_ = $stderr.isatty
12
- OS_IS_UNIX_ = %w{
11
+ STDERR_ISATTY_ = $stderr.isatty
12
+ OS_IS_UNIX_ = %w{
13
13
 
14
- darwin
15
- freebsd
16
- linux
17
- mingw32
18
- solaris
19
- sunos
20
- }.any? { |os| RUBY_PLATFORM =~ /#{os.downcase}/ }
21
- SHOULD_COLOURIZE_ = STDERR_ISATTY_ && OS_IS_UNIX_
14
+ darwin
15
+ freebsd
16
+ linux
17
+ mingw32
18
+ solaris
19
+ sunos
20
+ }.any? { |os| RUBY_PLATFORM =~ /#{os.downcase}/ }
21
+ SHOULD_COLOURIZE_ = STDERR_ISATTY_ && OS_IS_UNIX_
22
22
 
23
- module ColourInitialiser
23
+ module ColourInitialiser
24
24
 
25
- def self.extended other
25
+ def self.extended other
26
26
 
27
- other::COLOURS.each do |name, value|
27
+ other::COLOURS.each do |name, value|
28
28
 
29
- other.const_set(name.to_s.upcase, value)
29
+ other.const_set(name.to_s.upcase, value)
30
30
 
31
- if SHOULD_COLOURIZE_
31
+ if SHOULD_COLOURIZE_
32
32
 
33
- other.define_singleton_method(name) { |s| "\x1B[#{value}m#{s}\x1B[0m" }
34
- else
33
+ other.define_singleton_method(name) { |s| "\x1B[#{value}m#{s}\x1B[0m" }
34
+ else
35
35
 
36
- other.define_singleton_method(name) { |s| s }
37
- end
38
- end
39
- end
40
- end # module ColourInitialiser
41
- end # module Internal_
36
+ other.define_singleton_method(name) { |s| s }
37
+ end
38
+ end
39
+ end
40
+ end # module ColourInitialiser
41
+ end # module Internal_
42
42
 
43
- module AnsiEscapeSequences
43
+ module AnsiEscapeSequences
44
44
 
45
- module Foreground
45
+ module Foreground
46
46
 
47
- COLOURS = {
47
+ COLOURS = {
48
48
 
49
- blinking: 5,
50
- bold: 1,
51
- default: 39,
49
+ blinking: 5,
50
+ bold: 1,
51
+ default: 39,
52
52
 
53
- black: 30,
54
- red: 31,
55
- green: 32,
56
- yellow: 33,
57
- blue: 34,
58
- magenta: 35,
59
- cyan: 36,
60
- light_grey: 37,
53
+ black: 30,
54
+ red: 31,
55
+ green: 32,
56
+ yellow: 33,
57
+ blue: 34,
58
+ magenta: 35,
59
+ cyan: 36,
60
+ light_grey: 37,
61
61
 
62
- dark_grey: 90,
63
- bright_red: 91,
64
- bright_green: 92,
65
- bright_yellow: 93,
66
- bright_blue: 94,
67
- bright_magenta: 95,
68
- bright_cyan: 96,
69
- white: 97,
70
- }
62
+ dark_grey: 90,
63
+ bright_red: 91,
64
+ bright_green: 92,
65
+ bright_yellow: 93,
66
+ bright_blue: 94,
67
+ bright_magenta: 95,
68
+ bright_cyan: 96,
69
+ white: 97,
70
+ }
71
71
 
72
- extend Internal_::ColourInitialiser
73
- end # module Foreground
72
+ extend Internal_::ColourInitialiser
73
+ end # module Foreground
74
74
 
75
- module Background
75
+ module Background
76
76
 
77
- COLOURS = Hash[Foreground::COLOURS.reject { |k, v| [ :blinking, :bold, :default ].include? k }.map { |k, v| [ k, 10 + v ] }]
77
+ COLOURS = Hash[Foreground::COLOURS.reject { |k, v| [ :blinking, :bold, :default ].include? k }.map { |k, v| [ k, 10 + v ] }]
78
78
 
79
- extend Internal_::ColourInitialiser
80
- end # module Background
79
+ extend Internal_::ColourInitialiser
80
+ end # module Background
81
81
 
82
- module Special
82
+ module Special
83
83
 
84
- # TODO
84
+ # TODO
85
85
 
86
- end # module Special
87
- end # end AnsiEscapeSequences
86
+ end # module Special
87
+ end # end AnsiEscapeSequences
88
88
 
89
89
  end # module Console
90
90
  end # module Common
@@ -6,14 +6,14 @@
6
6
  # ::Pantheios::Services::MultiplexingLogService class
7
7
  #
8
8
  # Created: 14th June 2015
9
- # Updated: 15th August 2026
9
+ # Updated: 28th August 2026
10
10
  #
11
11
  # Home: https://github.com/synesissoftware/Pantheios.Ruby
12
12
  #
13
13
  # Author: Matthew Wilson
14
14
  #
15
- # Copyright (c) 2019-2020, Matthew Wilson and Synesis Information Systems
16
- # Copyright (c) 2015-2018, Matthew Wilson and Synesis Software
15
+ # Copyright (c) 2019-2026, Matthew Wilson and Synesis Information Systems
16
+ # Copyright (c) 2015-2019, Matthew Wilson and Synesis Software
17
17
  # All rights reserved.
18
18
  #
19
19
  # Redistribution and use in source and binary forms, with or without
@@ -60,214 +60,215 @@ module Services
60
60
  # +log(severity : Object, t : Time, prefix : String|Array, msg : String)+
61
61
  class MultiplexingLogService
62
62
 
63
- # @!visibility private
64
- module MultiplexingLogService_Internals_ # :nodoc: all
63
+ # @!visibility private
64
+ module MultiplexingLogService_Internals_ # :nodoc: all
65
65
 
66
- class ServiceManagementInfo
66
+ class ServiceManagementInfo
67
67
 
68
- def initialize svc
68
+ def initialize svc
69
69
 
70
- @service = svc
71
- end
70
+ @service = svc
71
+ end
72
72
 
73
- attr_reader :service
74
- end
75
- end
73
+ attr_reader :service
74
+ end
75
+ end
76
76
 
77
- # Initializes the instance with an array of log services, according to
78
- # the given options
79
- #
80
- # ===Signature
81
- #
82
- # * *Parameters:*
83
- # - +services+:: [ ::Array ] An array of instances that observe the
84
- # Log Service protocol
85
- # - +options+:: [ ::Hash] options
86
- #
87
- # * *Options:*
88
- # - +:level_cache_mode+:: [ ::Symbol ] Specifies the mode of severity
89
- # level caching, and must be one of the following values:
90
- # * +:none+:: no severity level caching is performed. This is the
91
- # default because it is completely thread-safe, but it is the
92
- # slowest mode, and users are advised to specify another mode
93
- # suitable to their use
94
- # * +:thread_fixed+:: remembers the response of each multiplexed log
95
- # service to each severity level on a thread-specific basis
96
- # * +:process_fixed+:: remembers the response of each multiplexed
97
- # log service to each severity level and then remembers that for
98
- # the duration of the lifetime of the instance
99
- # - +:unsync_process_lcm+:: [ boolean ] If truey, causes
100
- # +:process_fixed+ +:level_cache_mode+ to NOT be synchronised; the
101
- # default is for it to be synchronised using an internal +Mutex+
102
- # instance
103
- def initialize services, **options
77
+ # Initializes the instance with an array of log services, according to
78
+ # the given options
79
+ #
80
+ # ===Signature
81
+ #
82
+ # * *Parameters:*
83
+ # - +services+:: [ ::Array ] An array of instances that observe the
84
+ # Log Service protocol
85
+ # - +options+:: [ ::Hash] options
86
+ #
87
+ # * *Options:*
88
+ # - +:level_cache_mode+:: [ ::Symbol ] Specifies the mode of severity
89
+ # level caching, and must be one of the following values:
90
+ # * +:none+:: no severity level caching is performed. This is the
91
+ # default because it is completely thread-safe, but it is the
92
+ # slowest mode, and users are advised to specify another mode
93
+ # suitable to their use
94
+ # * +:thread_fixed+:: remembers the response of each multiplexed log
95
+ # service to each severity level on a thread-specific basis
96
+ # * +:process_fixed+:: remembers the response of each multiplexed
97
+ # log service to each severity level and then remembers that for
98
+ # the duration of the lifetime of the instance
99
+ # - +:unsync_process_lcm+:: [ boolean ] If truey, causes
100
+ # +:process_fixed+ +:level_cache_mode+ to NOT be synchronised; the
101
+ # default is for it to be synchronised using an internal +Mutex+
102
+ # instance
103
+ def initialize services, **options
104
104
 
105
- @tss_sym = self.to_s.to_sym
106
- @services = services.map { |svc| MultiplexingLogService_Internals_::ServiceManagementInfo.new svc }
107
- @options = options.dup
108
- @mode = options[:level_cache_mode]
109
- @unsync_pf = options[:unsync_process_lcm]
105
+ @tss_sym = self.to_s.to_sym
106
+ @services = services.map { |svc| MultiplexingLogService_Internals_::ServiceManagementInfo.new svc }
107
+ @options = options.dup
108
+ @mode = options[:level_cache_mode]
109
+ @unsync_pf = options[:unsync_process_lcm]
110
110
 
111
- @process_m = {}
112
- @mx = Mutex.new unless @unsync_pf
113
- end
111
+ @process_m = {}
112
+ @requires_prefix = nil
113
+ @mx = Mutex.new unless @unsync_pf
114
+ end
114
115
 
115
- private
116
+ private
116
117
 
117
- # { svc => { sev => flag } }
118
- def get_tss_svc_sev_map_
118
+ # { svc => { sev => flag } }
119
+ def get_tss_svc_sev_map_
119
120
 
120
- sym = @tss_sym
121
- tc = Thread.current
122
- m = tc.thread_variable_get sym
121
+ sym = @tss_sym
122
+ tc = Thread.current
123
+ m = tc.thread_variable_get sym
123
124
 
124
- unless m
125
+ unless m
125
126
 
126
- tc.thread_variable_set sym, (m = {})
127
- end
127
+ tc.thread_variable_set sym, (m = {})
128
+ end
128
129
 
129
- m
130
- end
130
+ m
131
+ end
131
132
 
132
- def svc_sev_logged_tf_ m, svc, severity
133
+ def svc_sev_logged_tf_ m, svc, severity
133
134
 
134
- m[svc.object_id] ||= {}
135
+ m[svc.object_id] ||= {}
135
136
 
136
- unless m[svc.object_id].has_key? severity
137
+ unless m[svc.object_id].has_key? severity
137
138
 
138
- r = svc.severity_logged? severity
139
+ r = svc.severity_logged? severity
139
140
 
140
- m[svc.object_id][severity] = r
141
- else
141
+ m[svc.object_id][severity] = r
142
+ else
142
143
 
143
- r = m[svc.object_id][severity]
144
- end
144
+ r = m[svc.object_id][severity]
145
+ end
145
146
 
146
- r
147
- end
147
+ r
148
+ end
148
149
 
149
- def svc_sev_logged_pf_ m, svc, severity
150
+ def svc_sev_logged_pf_ m, svc, severity
150
151
 
151
- m[svc.object_id] ||= {}
152
+ m[svc.object_id] ||= {}
152
153
 
153
- unless m[svc.object_id].has_key? severity
154
+ unless m[svc.object_id].has_key? severity
154
155
 
155
- r = svc.severity_logged? severity
156
+ r = svc.severity_logged? severity
156
157
 
157
- m[svc.object_id][severity] = r
158
- else
158
+ m[svc.object_id][severity] = r
159
+ else
159
160
 
160
- r = m[svc.object_id][severity]
161
- end
161
+ r = m[svc.object_id][severity]
162
+ end
162
163
 
163
- r
164
- end
164
+ r
165
+ end
165
166
 
166
- def sev_logged_pf_ m, severity
167
+ def sev_logged_pf_ m, severity
167
168
 
168
- @services.any? { |smi| svc_sev_logged_pf_ m, smi.service, severity }
169
- end
170
- public
169
+ @services.any? { |smi| svc_sev_logged_pf_ m, smi.service, severity }
170
+ end
171
+ public
171
172
 
172
- # Indicates whether any of the services require a prefix and, if so,
173
- # what it may require
174
- #
175
- # === Return
176
- # (+false+, +true+, +:parts+) An indicator what the most needy of the
177
- # multiplexed services requires
178
- def requires_prefix?
173
+ # Indicates whether any of the services require a prefix and, if so,
174
+ # what it may require
175
+ #
176
+ # === Return
177
+ # (+false+, +true+, +:parts+) An indicator what the most needy of the
178
+ # multiplexed services requires
179
+ def requires_prefix?
179
180
 
180
- return @requires_prefix unless @requires_prefix.nil?
181
+ return @requires_prefix unless @requires_prefix.nil?
181
182
 
182
- requires_prefix = false
183
+ requires_prefix = false
183
184
 
184
- @services.each do |svc|
185
+ @services.each do |svc|
185
186
 
186
- if svc.respond_to? :requires_prefix?
187
+ if svc.respond_to? :requires_prefix?
187
188
 
188
- case rp = svc.requires_prefix?
189
- when nil, false
189
+ case rp = svc.requires_prefix?
190
+ when nil, false
190
191
 
191
- ;
192
- when true
192
+ ;
193
+ when true
193
194
 
194
- requires_prefix ||= true
195
- when :parts
195
+ requires_prefix ||= true
196
+ when :parts
196
197
 
197
- requires_prefix = rp
198
- break
199
- else
198
+ requires_prefix = rp
199
+ break
200
+ else
200
201
 
201
- warn "unrecognised return from requires_prefix? for service #{svc}: #{rp} (#{rp.class})"
202
- end
203
- end
204
- end
202
+ warn "unrecognised return from requires_prefix? for service #{svc}: #{rp} (#{rp.class})"
203
+ end
204
+ end
205
+ end
205
206
 
206
- @requires_prefix = requires_prefix
207
- end
207
+ @requires_prefix = requires_prefix
208
+ end
208
209
 
209
- # Indicates whether the given severity is to be logged by any of the
210
- # multiplexed log services
211
- def severity_logged? severity
210
+ # Indicates whether the given severity is to be logged by any of the
211
+ # multiplexed log services
212
+ def severity_logged? severity
212
213
 
213
- case @mode
214
- when :process_fixed
214
+ case @mode
215
+ when :process_fixed
215
216
 
216
- if @unsync_pf
217
+ if @unsync_pf
217
218
 
218
- sev_logged_pf_ @process_m, severity
219
- else
219
+ sev_logged_pf_ @process_m, severity
220
+ else
220
221
 
221
- @mx.synchronize { sev_logged_pf_ @process_m, severity }
222
- end
223
- when :thread_fixed
222
+ @mx.synchronize { sev_logged_pf_ @process_m, severity }
223
+ end
224
+ when :thread_fixed
224
225
 
225
- m = get_tss_svc_sev_map_
226
+ m = get_tss_svc_sev_map_
226
227
 
227
- @services.any? do |smi|
228
+ @services.any? do |smi|
228
229
 
229
- svc = smi.service
230
+ svc = smi.service
230
231
 
231
- svc_sev_logged_tf_ m, svc, severity
232
- end
233
- else # :none
232
+ svc_sev_logged_tf_ m, svc, severity
233
+ end
234
+ else # :none
234
235
 
235
- @services.any? { |smi| smi.service.severity_logged? severity }
236
- end
237
- end
236
+ @services.any? { |smi| smi.service.severity_logged? severity }
237
+ end
238
+ end
238
239
 
239
- def log sev, t, pref, msg
240
+ def log sev, t, pref, msg
240
241
 
241
- tss_m = :thread_fixed == @mode ? get_tss_svc_sev_map_ : nil
242
+ tss_m = :thread_fixed == @mode ? get_tss_svc_sev_map_ : nil
242
243
 
243
- @services.each do |smi|
244
+ @services.each do |smi|
244
245
 
245
- svc = smi.service
246
+ svc = smi.service
246
247
 
247
- case @mode
248
- when :process_fixed
248
+ case @mode
249
+ when :process_fixed
249
250
 
250
- if @unsync_pf
251
+ if @unsync_pf
251
252
 
252
- isl = svc_sev_logged_pf_ @process_m, svc, sev
253
- else
253
+ isl = svc_sev_logged_pf_ @process_m, svc, sev
254
+ else
254
255
 
255
- isl = @mx.synchronize { svc_sev_logged_pf_ @process_m, svc, sev }
256
- end
257
- when :thread_fixed
256
+ isl = @mx.synchronize { svc_sev_logged_pf_ @process_m, svc, sev }
257
+ end
258
+ when :thread_fixed
258
259
 
259
- m = tss_m
260
+ m = tss_m
260
261
 
261
- isl = svc_sev_logged_tf_ m, svc, sev
262
- else # :none
262
+ isl = svc_sev_logged_tf_ m, svc, sev
263
+ else # :none
263
264
 
264
- isl = svc.severity_logged? sev
265
- end
265
+ isl = svc.severity_logged? sev
266
+ end
266
267
 
267
268
 
268
- svc.log sev, t, pref, msg if isl
269
- end
270
- end
269
+ svc.log sev, t, pref, msg if isl
270
+ end
271
+ end
271
272
  end
272
273
 
273
274
  end # module Services
@@ -6,14 +6,14 @@
6
6
  # class
7
7
  #
8
8
  # Created: 14th June 2015
9
- # Updated: 15th August 2026
9
+ # Updated: 28th August 2026
10
10
  #
11
11
  # Home: https://github.com/synesissoftware/Pantheios.Ruby
12
12
  #
13
13
  # Author: Matthew Wilson
14
14
  #
15
- # Copyright (c) 2019-2020, Matthew Wilson and Synesis Information Systems
16
- # Copyright (c) 2015-2018, Matthew Wilson and Synesis Software
15
+ # Copyright (c) 2019-2026, Matthew Wilson and Synesis Information Systems
16
+ # Copyright (c) 2015-2019, Matthew Wilson and Synesis Software
17
17
  # All rights reserved.
18
18
  #
19
19
  # Redistribution and use in source and binary forms, with or without
@@ -60,15 +60,15 @@ module Services
60
60
  # +log(severity : Object, t : Time, prefix : String|Array, msg : String)+
61
61
  class NullLogService
62
62
 
63
- def severity_logged? severity
63
+ def severity_logged? severity
64
64
 
65
- false
66
- end
65
+ false
66
+ end
67
67
 
68
- def log sev, t, pref, msg
68
+ def log sev, t, pref, msg
69
69
 
70
- ;
71
- end
70
+ ;
71
+ end
72
72
  end
73
73
 
74
74
  end # module Services
@@ -6,14 +6,14 @@
6
6
  # ::Pantheios::Services::SimpleConsoleLogService class
7
7
  #
8
8
  # Created: 14th June 2015
9
- # Updated: 15th August 2026
9
+ # Updated: 28th August 2026
10
10
  #
11
11
  # Home: https://github.com/synesissoftware/Pantheios.Ruby
12
12
  #
13
13
  # Author: Matthew Wilson
14
14
  #
15
- # Copyright (c) 2019-2020, Matthew Wilson and Synesis Information Systems
16
- # Copyright (c) 2015-2018, Matthew Wilson and Synesis Software
15
+ # Copyright (c) 2019-2026, Matthew Wilson and Synesis Information Systems
16
+ # Copyright (c) 2015-2019, Matthew Wilson and Synesis Software
17
17
  # All rights reserved.
18
18
  #
19
19
  # Redistribution and use in source and binary forms, with or without
@@ -60,27 +60,27 @@ module Services
60
60
  # +log(severity : Object, t : Time, prefix : String|Array, msg : String)+
61
61
  class SimpleConsoleLogService
62
62
 
63
- def severity_logged? severity
63
+ def severity_logged? severity
64
64
 
65
- true
66
- end
65
+ true
66
+ end
67
67
 
68
- def log sev, t, pref, msg
68
+ def log sev, t, pref, msg
69
69
 
70
- stm = infer_stream sev
70
+ stm = infer_stream sev
71
71
 
72
- stm.puts "#{pref}#{msg}"
73
- end
72
+ stm.puts "#{pref}#{msg}"
73
+ end
74
74
 
75
- # Overrideable method that determines which stream to write, based on a
76
- # severity. This implementation always returns +$stderr+
77
- #
78
- # Overrides must return an object that supports the +puts(String)+
79
- # method
80
- def infer_stream sev
75
+ # Overrideable method that determines which stream to write, based on a
76
+ # severity. This implementation always returns +$stderr+
77
+ #
78
+ # Overrides must return an object that supports the +puts(String)+
79
+ # method
80
+ def infer_stream sev
81
81
 
82
- $stderr
83
- end
82
+ $stderr
83
+ end
84
84
  end # class SimpleConsoleLogService
85
85
 
86
86
  end # module Services