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
@@ -1,4 +1,4 @@
1
-
1
+ # frozen_string_literal: true
2
2
  # ######################################################################## #
3
3
  # File: lib/pantheios/front_ends/threshold_front_end.rb
4
4
  #
@@ -6,13 +6,13 @@
6
6
  # class
7
7
  #
8
8
  # Created: 3rd June 2020
9
- # Updated: 4th June 2020
9
+ # Updated: 28th August 2026
10
10
  #
11
- # Home: http://github.com/synesissoftware/Pantheios-Ruby
11
+ # Home: https://github.com/synesissoftware/Pantheios.Ruby
12
12
  #
13
13
  # Author: Matthew Wilson
14
14
  #
15
- # Copyright (c) 2020, Matthew Wilson and Synesis Information Systems
15
+ # Copyright (c) 2020-2026, Matthew Wilson and Synesis Information Systems
16
16
  # All rights reserved.
17
17
  #
18
18
  # Redistribution and use in source and binary forms, with or without
@@ -60,83 +60,83 @@ module FrontEnds
60
60
  # the instance method +severity_logged?(severity : Object)+
61
61
  class ThresholdFrontEnd
62
62
 
63
- # Initialises the instance
64
- #
65
- # === Signature
66
- #
67
- # * *Parameters:*
68
- # - +threshold_severity+ [ ::Symbol ] The threshold severity
69
- #
70
- # * *Options:*
71
- # - +value_lookup_map+ [ ::Hash ] A map that is used to lookup
72
- # +severity+ values (that are not +::Integer+) in
73
- # +severity_logged?+. May be +nil+, in which case
74
- # +::Pantheios::ApplicationLayer::StockSeverityLevels::STOCK_SEVERITY_LEVEL_VALUES+
75
- # is used
76
- #
77
- # * *Exceptions:*
78
- # - +::TypeError+ raised if a value given for +:value_lookup_map+ is
79
- # not a ::hash
80
- def initialize(threshold_severity, **options)
81
-
82
- m = options[:value_lookup_map]
83
-
84
- raise TypeError, "value given for :value_lookup_map must be a #{::Hash}" if m && !m.respond_to?(:to_hash)
85
-
86
- if m
87
-
88
- @value_lookup_map = m
89
- @relativity_lookup_map = ::Hash.new(:relative)
90
- else
91
-
92
- @value_lookup_map = ::Pantheios::ApplicationLayer::StockSeverityLevels::STOCK_SEVERITY_LEVEL_VALUES
93
- @relativity_lookup_map = ::Pantheios::ApplicationLayer::StockSeverityLevels::STOCK_SEVERITY_LEVELS_RELATIVE
94
- end
95
-
96
- self.threshold = threshold_severity
97
- end
98
-
99
- # Determines whether a given severity is logged
100
- #
101
- # === Signature
102
- #
103
- # * *Parameters:*
104
- # - +severity+:: The severity level, which should be a known log
105
- # severity symbol or an integral equivalent
106
- #
107
- # * *Returns:*
108
- # a +truey+ value if the severity should be logged; a +falsey+ value
109
- # otherwise
110
- def severity_logged? severity
111
-
112
- case severity
113
- when ::Integer
114
-
115
- v = severity
116
- else
117
-
118
- v = @value_lookup_map[severity] or warn "unknown severity level '#{severity}' (#{severity.class})"
119
- end
120
-
121
- return true if v.nil?
122
-
123
- v <= @threshold_v
124
- end
125
-
126
- # assigns the threshold
127
- #
128
- # * *Parameters:*
129
- # - +threshold_severity+ [ ::Symbol ] The threshold severity
130
- def threshold=(threshold_severity)
131
-
132
- raise TypeError, "threshold_severity must be a #{::Symbol}" unless ::Symbol === threshold_severity
133
-
134
- @threshold_v = @value_lookup_map[threshold_severity] if @relativity_lookup_map[threshold_severity] or raise ArgumentError, "unknown threshold severity level '#{threshold_severity}' (#{threshold_severity.class})"
135
- @threshold = threshold_severity
136
-
137
- nil
138
- end
139
- attr_reader :threshold
63
+ # Initialises the instance
64
+ #
65
+ # === Signature
66
+ #
67
+ # * *Parameters:*
68
+ # - +threshold_severity+ [ ::Symbol ] The threshold severity
69
+ #
70
+ # * *Options:*
71
+ # - +value_lookup_map+ [ ::Hash ] A map that is used to lookup
72
+ # +severity+ values (that are not +::Integer+) in
73
+ # +severity_logged?+. May be +nil+, in which case
74
+ # +::Pantheios::ApplicationLayer::StockSeverityLevels::STOCK_SEVERITY_LEVEL_VALUES+
75
+ # is used
76
+ #
77
+ # * *Exceptions:*
78
+ # - +::TypeError+ raised if a value given for +:value_lookup_map+ is
79
+ # not a ::hash
80
+ def initialize(threshold_severity, **options)
81
+
82
+ m = options[:value_lookup_map]
83
+
84
+ raise TypeError, "value given for :value_lookup_map must be a #{::Hash}" if m && !m.respond_to?(:to_hash)
85
+
86
+ if m
87
+
88
+ @value_lookup_map = m
89
+ @relativity_lookup_map = ::Hash.new(:relative)
90
+ else
91
+
92
+ @value_lookup_map = ::Pantheios::ApplicationLayer::StockSeverityLevels::STOCK_SEVERITY_LEVEL_VALUES
93
+ @relativity_lookup_map = ::Pantheios::ApplicationLayer::StockSeverityLevels::STOCK_SEVERITY_LEVELS_RELATIVE
94
+ end
95
+
96
+ self.threshold = threshold_severity
97
+ end
98
+
99
+ # Determines whether a given severity is logged
100
+ #
101
+ # === Signature
102
+ #
103
+ # * *Parameters:*
104
+ # - +severity+:: The severity level, which should be a known log
105
+ # severity symbol or an integral equivalent
106
+ #
107
+ # * *Returns:*
108
+ # a +truey+ value if the severity should be logged; a +falsey+ value
109
+ # otherwise
110
+ def severity_logged? severity
111
+
112
+ case severity
113
+ when ::Integer
114
+
115
+ v = severity
116
+ else
117
+
118
+ v = @value_lookup_map[severity] or warn "unknown severity level '#{severity}' (#{severity.class})"
119
+ end
120
+
121
+ return true if v.nil?
122
+
123
+ v <= @threshold_v
124
+ end
125
+
126
+ # assigns the threshold
127
+ #
128
+ # * *Parameters:*
129
+ # - +threshold_severity+ [ ::Symbol ] The threshold severity
130
+ def threshold=(threshold_severity)
131
+
132
+ raise TypeError, "threshold_severity must be a #{::Symbol}" unless ::Symbol === threshold_severity
133
+
134
+ @threshold_v = @value_lookup_map[threshold_severity] if @relativity_lookup_map[threshold_severity] or raise ArgumentError, "unknown threshold severity level '#{threshold_severity}' (#{threshold_severity.class})"
135
+ @threshold = threshold_severity
136
+
137
+ nil
138
+ end
139
+ attr_reader :threshold
140
140
 
141
141
  end # class ThresholdFrontEnd
142
142
 
@@ -1,18 +1,18 @@
1
-
1
+ # frozen_string_literal: true
2
2
  # ######################################################################## #
3
3
  # File: lib/pantheios/globals.rb
4
4
  #
5
5
  # Purpose: The Pantheios.Ruby "globals" (::Pantheios::Globals)
6
6
  #
7
7
  # Created: 24th December 2017
8
- # Updated: 3rd 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-2020, Matthew Wilson and Synesis Information Systems
15
- # Copyright (c) 2017-2018, Matthew Wilson and Synesis Software
14
+ # Copyright (c) 2019-2026, Matthew Wilson and Synesis Information Systems
15
+ # Copyright (c) 2017-2019, Matthew Wilson and Synesis Software
16
16
  # All rights reserved.
17
17
  #
18
18
  # Redistribution and use in source and binary forms, with or without
@@ -89,70 +89,70 @@ module Pantheios
89
89
  #
90
90
  module Globals
91
91
 
92
- # @!visibility private
93
- module Internals_ # :nodoc: all
92
+ # @!visibility private
93
+ module Internals_ # :nodoc: all
94
94
 
95
- BOOLEAN_CLASSES = [ ::FalseClass, ::TrueClass ]
96
- TRUTHY_CLASSES = BOOLEAN_CLASSES + [ ::NilClass ]
95
+ BOOLEAN_CLASSES = [ ::FalseClass, ::TrueClass ]
96
+ TRUTHY_CLASSES = BOOLEAN_CLASSES + [ ::NilClass ]
97
97
 
98
- PROCESS_NAME_CLASSES = [ ::Symbol, ::String ]
99
- end
98
+ PROCESS_NAME_CLASSES = [ ::Symbol, ::String ]
99
+ end
100
100
 
101
- # @!visibility private
102
- module Helpers_ # :nodoc: all
101
+ # @!visibility private
102
+ module Helpers_ # :nodoc: all
103
103
 
104
- def self.cattr receiver, name, types, initial_value, **options
104
+ def self.cattr receiver, name, types, initial_value, **options
105
105
 
106
- if options[:boolean] && types.nil?
106
+ if options[:boolean] && types.nil?
107
107
 
108
- types = Internals_::TRUTHY_CLASSES
109
- end
108
+ types = Internals_::TRUTHY_CLASSES
109
+ end
110
110
 
111
- types = nil if !types.nil? && types.empty?
111
+ types = nil if !types.nil? && types.empty?
112
112
 
113
- receiver.class_eval do
113
+ receiver.class_eval do
114
114
 
115
- field_name = '@' + name
116
- get_name = name
117
- get_name += '?' if options[:boolean]
115
+ field_name = '@' + name
116
+ get_name = name
117
+ get_name += '?' if options[:boolean]
118
118
 
119
- instance_variable_set field_name, initial_value
119
+ instance_variable_set field_name, initial_value
120
120
 
121
- define_singleton_method(get_name) do
121
+ define_singleton_method(get_name) do
122
122
 
123
- instance_variable_get field_name
124
- end
123
+ instance_variable_get field_name
124
+ end
125
125
 
126
- define_singleton_method(name + '=') do |v|
126
+ define_singleton_method(name + '=') do |v|
127
127
 
128
- if types
128
+ if types
129
129
 
130
- warn "Assigning to #{__method__} with argument of invalid type - #{v.class} given; one of #{types.join(', ')} required" unless types.any? { |c| c === v }
131
- end
130
+ warn "Assigning to #{__method__} with argument of invalid type - #{v.class} given; one of #{types.join(', ')} required" unless types.any? { |c| c === v }
131
+ end
132
132
 
133
- instance_variable_set field_name, v
134
- end
135
- end
136
- end
137
- end
133
+ instance_variable_set field_name, v
134
+ end
135
+ end
136
+ end
137
+ end
138
138
 
139
- Helpers_.cattr self, 'HAS_CASCADED_INCLUDES', Internals_::BOOLEAN_CLASSES, true
139
+ Helpers_.cattr self, 'HAS_CASCADED_INCLUDES', Internals_::BOOLEAN_CLASSES, true
140
140
 
141
- Helpers_.cattr self, 'INITIAL_SERVICE_INSTANCES', nil, nil
141
+ Helpers_.cattr self, 'INITIAL_SERVICE_INSTANCES', nil, nil
142
142
 
143
- Helpers_.cattr self, 'INITIAL_SERVICE_CLASSES', nil, nil
143
+ Helpers_.cattr self, 'INITIAL_SERVICE_CLASSES', nil, nil
144
144
 
145
- Helpers_.cattr self, 'MAIN_THREAD_NAME', [ ::Array, ::String ], nil
145
+ Helpers_.cattr self, 'MAIN_THREAD_NAME', [ ::Array, ::String ], nil
146
146
 
147
- Helpers_.cattr self, 'PROCESS_NAME', Internals_::PROCESS_NAME_CLASSES, nil
147
+ Helpers_.cattr self, 'PROCESS_NAME', Internals_::PROCESS_NAME_CLASSES, nil
148
148
 
149
- Helpers_.cattr self, 'SYNCHRONISED_SEVERITY_LOGGED', nil, true, boolean: true
149
+ Helpers_.cattr self, 'SYNCHRONISED_SEVERITY_LOGGED', nil, true, boolean: true
150
150
 
151
- # @!visibility private
152
- def self.included receiver # :nodoc:
151
+ # @!visibility private
152
+ def self.included receiver # :nodoc:
153
153
 
154
- abort "Attempt to include #{self} into #{receiver}. This is not allowed"
155
- end
154
+ abort "Attempt to include #{self} into #{receiver}. This is not allowed"
155
+ end
156
156
 
157
157
  end # module Globals
158
158
  end # module Pantheios
@@ -1,4 +1,4 @@
1
-
1
+ # frozen_string_literal: true
2
2
  # ######################################################################## #
3
3
  # File: lib/pantheios/services/coloured_console_log_service.rb
4
4
  #
@@ -6,13 +6,13 @@
6
6
  # ::Pantheios::Services::ColouredConsoleLogService class
7
7
  #
8
8
  # Created: 19th June 2019
9
- # Updated: 4th June 2020
9
+ # Updated: 28th August 2026
10
10
  #
11
- # Home: http://github.com/synesissoftware/Pantheios-Ruby
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
15
+ # Copyright (c) 2019-2026, Matthew Wilson and Synesis Information Systems
16
16
  # Copyright (c) 2019, Matthew Wilson and Synesis Software
17
17
  # All rights reserved.
18
18
  #
@@ -62,138 +62,138 @@ module Services
62
62
  # +log(severity : Object, t : Time, prefix : String|Array, msg : String)+
63
63
  class ColouredConsoleLogService
64
64
 
65
- module Constants
65
+ module Constants
66
66
 
67
- include ::Pantheios::Services::Common::Console::AnsiEscapeSequences
68
- end # module Constants
67
+ include ::Pantheios::Services::Common::Console::AnsiEscapeSequences
68
+ end # module Constants
69
69
 
70
- def self.requires_prefix?
70
+ def self.requires_prefix?
71
71
 
72
- return @requires_prefix unless @requires_prefix.nil?
72
+ return @requires_prefix unless @requires_prefix.nil?
73
73
 
74
- @requires_prefix = ::Pantheios::Services::Common::Console::Internal_::SHOULD_COLOURIZE_ ? :parts : false
75
- end
74
+ @requires_prefix = ::Pantheios::Services::Common::Console::Internal_::SHOULD_COLOURIZE_ ? :parts : false
75
+ end
76
76
 
77
- def requires_prefix?
77
+ def requires_prefix?
78
78
 
79
- self.class.requires_prefix?
80
- end
79
+ self.class.requires_prefix?
80
+ end
81
81
 
82
- def severity_logged? severity
82
+ def severity_logged? severity
83
83
 
84
- true
85
- end
84
+ true
85
+ end
86
86
 
87
- def log sev, t, pref, msg
87
+ def log sev, t, pref, msg
88
88
 
89
- stm = infer_stream sev
89
+ stm = infer_stream sev
90
90
 
91
- if requires_prefix?
91
+ if requires_prefix?
92
92
 
93
- pref = pref.map do |part|
93
+ pref = pref.map do |part|
94
94
 
95
- bg = Constants::Background
96
- fg = Constants::Foreground
95
+ bg = Constants::Background
96
+ fg = Constants::Foreground
97
97
 
98
- if part.respond_to?(:severity)
98
+ if part.respond_to?(:severity)
99
99
 
100
- part = fg.bold part
100
+ part = fg.bold part
101
101
 
102
- case sev
103
- when :violation
102
+ case sev
103
+ when :violation
104
104
 
105
- part = bg.red part
106
- #part = fg.bright_magenta part
107
- part = fg.bright_yellow part
108
- part = fg.blinking part
109
- when :alert
105
+ part = bg.red part
106
+ #part = fg.bright_magenta part
107
+ part = fg.bright_yellow part
108
+ part = fg.blinking part
109
+ when :alert
110
110
 
111
- part = bg.red part
112
- part = fg.bright_cyan part
113
- part = fg.blinking part
114
- when :critical
111
+ part = bg.red part
112
+ part = fg.bright_cyan part
113
+ part = fg.blinking part
114
+ when :critical
115
115
 
116
- part = bg.red part
117
- part = fg.white part
118
- when :failure
116
+ part = bg.red part
117
+ part = fg.white part
118
+ when :failure
119
119
 
120
- part = bg.yellow part
121
- part = fg.red part
122
- when :warning
120
+ part = bg.yellow part
121
+ part = fg.red part
122
+ when :warning
123
123
 
124
- part = bg.yellow part
125
- part = fg.blue part
126
- when :notice
124
+ part = bg.yellow part
125
+ part = fg.blue part
126
+ when :notice
127
127
 
128
- part = bg.dark_grey part
129
- part = fg.white part
130
- when :informational
128
+ part = bg.dark_grey part
129
+ part = fg.white part
130
+ when :informational
131
131
 
132
- part = bg.dark_grey part
133
- part = fg.light_grey part
134
- when :debug0
132
+ part = bg.dark_grey part
133
+ part = fg.light_grey part
134
+ when :debug0
135
135
 
136
- part = bg.blue part
137
- part = fg.light_grey part
138
- when :debug1
136
+ part = bg.blue part
137
+ part = fg.light_grey part
138
+ when :debug1
139
139
 
140
- part = bg.blue part
141
- part = fg.light_grey part
142
- when :debug2
140
+ part = bg.blue part
141
+ part = fg.light_grey part
142
+ when :debug2
143
143
 
144
- part = bg.blue part
145
- part = fg.light_grey part
146
- when :debug3
144
+ part = bg.blue part
145
+ part = fg.light_grey part
146
+ when :debug3
147
147
 
148
- part = bg.blue part
149
- part = fg.light_grey part
150
- when :debug4
148
+ part = bg.blue part
149
+ part = fg.light_grey part
150
+ when :debug4
151
151
 
152
- part = bg.blue part
153
- part = fg.light_grey part
154
- when :debug5
152
+ part = bg.blue part
153
+ part = fg.light_grey part
154
+ when :debug5
155
155
 
156
- part = bg.blue part
157
- part = fg.light_grey part
158
- when :trace
156
+ part = bg.blue part
157
+ part = fg.light_grey part
158
+ when :trace
159
159
 
160
- part = bg.blue part
161
- part = fg.light_grey part
162
- when :benchmark
160
+ part = bg.blue part
161
+ part = fg.light_grey part
162
+ when :benchmark
163
163
 
164
- part = bg.black part
165
- part = fg.light_grey part
166
- else
164
+ part = bg.black part
165
+ part = fg.light_grey part
166
+ else
167
167
 
168
- ;
169
- end
170
- else
168
+ ;
169
+ end
170
+ else
171
171
 
172
- part = fg.dark_grey part
173
- end
172
+ part = fg.dark_grey part
173
+ end
174
174
 
175
- part
176
- end.join(', ')
175
+ part
176
+ end.join(', ')
177
177
 
178
- pref = '[' + pref + ']: '
178
+ pref = '[' + pref + ']: '
179
179
 
180
- #pref = pref.map { |pp| pp.severity? ? map_sev_(sev) : sev }.join(
181
- end
180
+ #pref = pref.map { |pp| pp.severity? ? map_sev_(sev) : sev }.join(
181
+ end
182
182
 
183
- stm.puts "#{pref}#{msg}"
184
- end
183
+ stm.puts "#{pref}#{msg}"
184
+ end
185
185
 
186
- # Overrideable method that determines which stream to write, based on a
187
- # severity. This implementation always returns +$stderr+
188
- #
189
- # Overrides must return an object that supports the +puts(String)+
190
- # method
191
- def infer_stream sev
186
+ # Overrideable method that determines which stream to write, based on a
187
+ # severity. This implementation always returns +$stderr+
188
+ #
189
+ # Overrides must return an object that supports the +puts(String)+
190
+ # method
191
+ def infer_stream sev
192
192
 
193
- $stderr
194
- end
193
+ $stderr
194
+ end
195
195
 
196
- private
196
+ private
197
197
  end # class ColouredConsoleLogService
198
198
 
199
199
  end # module Services