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/services/simple_file_log_service.rb
4
4
  #
@@ -6,14 +6,14 @@
6
6
  # ::Pantheios::Services::SimpleFileLogService class
7
7
  #
8
8
  # Created: 17th June 2015
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
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
@@ -64,160 +64,159 @@ module Services
64
64
  # +log(severity : Object, t : Time, prefix : String|Array, msg : String)+
65
65
  class SimpleFileLogService
66
66
 
67
- module SimpleFileLogService_Constants
67
+ module SimpleFileLogService_Constants
68
68
 
69
- DEFAULT_ROLL_DEPTH = 7
70
- DEFAULT_ROLL_SIZE = 1024 * 1024
69
+ DEFAULT_ROLL_DEPTH = 7
70
+ DEFAULT_ROLL_SIZE = 1024 * 1024
71
71
 
72
- RECOGNISED_OPTIONS = %w{ roll_depth roll_period roll_size }.map { |s| s.to_sym }
72
+ RECOGNISED_OPTIONS = %w{ roll_depth roll_period roll_size }.map { |s| s.to_sym }
73
73
 
74
- end # module SimpleFileLogService_Constants
74
+ end # module SimpleFileLogService_Constants
75
75
 
76
- #
77
- # === Signature
78
- #
79
- # * *Parameters:*
80
- # - +log_file_or_path+:: [ +::File+, +::IO+, +::String+ ] A file or an
81
- # IO that will be used as the target of the log statements, or a
82
- # string specifying the path of the file to be used as the target
83
- # - +options+:: [ ::Hash ] Options. Options other than those listed
84
- # are ignored silently (except if +$DEBUG+, in which case a
85
- # +warn+ing will be issued)
86
- #
87
- # * *Options:*
88
- # - +:roll_period+:: ( +:daily+, +:weekly+, +:monthly+ ) The
89
- # periodicity of the log-file rolling. Ignored unless
90
- # +log_file_or_path+ is a +::String+. Ignored if either +:roll_size+
91
- # or +:roll_depth+ is specified
92
- # - +:roll_size+:: [ ::Integer, [ ::Integer, ::Integer ] ] An integer
93
- # specifying the size of the log file, or an array containing the
94
- # size of the log file and the depth of the log roll
95
- # - +:roll_depth+:: [ ::Integer ] The depth of the size-based log
96
- # rolling. Overrides the second element in an array specified for
97
- # +:roll_size+
98
- def initialize log_file_or_path, **options
76
+ #
77
+ # === Signature
78
+ #
79
+ # * *Parameters:*
80
+ # - +log_file_or_path+:: [ +::File+, +::IO+, +::String+ ] A file or an
81
+ # IO that will be used as the target of the log statements, or a
82
+ # string specifying the path of the file to be used as the target
83
+ # - +options+:: [ ::Hash ] Options. Options other than those listed
84
+ # are ignored silently (except if +$DEBUG+, in which case a
85
+ # +warn+ing will be issued)
86
+ #
87
+ # * *Options:*
88
+ # - +:roll_period+:: ( +:daily+, +:weekly+, +:monthly+ ) The
89
+ # periodicity of the log-file rolling. Ignored unless
90
+ # +log_file_or_path+ is a +::String+. Ignored if either +:roll_size+
91
+ # or +:roll_depth+ is specified
92
+ # - +:roll_size+:: [ ::Integer, [ ::Integer, ::Integer ] ] An integer
93
+ # specifying the size of the log file, or an array containing the
94
+ # size of the log file and the depth of the log roll
95
+ # - +:roll_depth+:: [ ::Integer ] The depth of the size-based log
96
+ # rolling. Overrides the second element in an array specified for
97
+ # +:roll_size+
98
+ def initialize log_file_or_path, **options
99
99
 
100
- roll_period = options[:roll_period]
101
- roll_size = options[:roll_size]
102
- roll_depth = options[:roll_depth]
100
+ roll_period = options[:roll_period]
101
+ roll_size = options[:roll_size]
102
+ roll_depth = options[:roll_depth]
103
103
 
104
- if $DEBUG
104
+ if $DEBUG
105
105
 
106
- options.each do |k, v|
106
+ options.each do |k, v|
107
107
 
108
- warn "#{self.class}##{__method__}(): ignoring unrecognised option '#{k}'" unless SimpleFileLogService_Constants::RECOGNISED_OPTIONS.include?(:k)
109
- end
110
- end
108
+ warn "#{self.class}##{__method__}(): ignoring unrecognised option '#{k}'" unless SimpleFileLogService_Constants::RECOGNISED_OPTIONS.include?(:k)
109
+ end
110
+ end
111
111
 
112
- if roll_period && (roll_size || roll_depth)
112
+ if roll_period && (roll_size || roll_depth)
113
113
 
114
- warn "#{self.class}##{__method__}(): caller specified :roll_depth/:roll_period with :roll_size to #{self.class}##{__method__}() - ignoring :roll_period" if $DEBUG
114
+ warn "#{self.class}##{__method__}(): caller specified :roll_depth/:roll_period with :roll_size to #{self.class}##{__method__}() - ignoring :roll_period" if $DEBUG
115
115
 
116
- roll_period = nil
117
- end
116
+ roll_period = nil
117
+ end
118
118
 
119
- if roll_size || roll_depth
119
+ if roll_size || roll_depth
120
120
 
121
- if ::Array === roll_size
121
+ if ::Array === roll_size
122
122
 
123
- roll_size, d = roll_size
123
+ roll_size, d = roll_size
124
124
 
125
- roll_depth ||= d
126
- end
125
+ roll_depth ||= d
126
+ end
127
127
 
128
- roll_size ||= SimpleFileLogService_Constants::DEFAULT_ROLL_SIZE
129
- roll_depth ||= SimpleFileLogService_Constants::DEFAULT_ROLL_DEPTH
130
- end
128
+ roll_size ||= SimpleFileLogService_Constants::DEFAULT_ROLL_SIZE
129
+ roll_depth ||= SimpleFileLogService_Constants::DEFAULT_ROLL_DEPTH
130
+ end
131
131
 
132
- logger_init_args = []
133
- logger_init_options = {}
132
+ logger_init_args = []
134
133
 
135
- if false;
136
- elsif roll_depth
134
+ if false;
135
+ elsif roll_depth
137
136
 
138
- logger_init_args << roll_depth
139
- logger_init_args << roll_size
140
- elsif roll_period
137
+ logger_init_args << roll_depth
138
+ logger_init_args << roll_size
139
+ elsif roll_period
141
140
 
142
- roll_period = roll_period.downcase.to_sym if ::String === roll_period
141
+ roll_period = roll_period.downcase.to_sym if ::String === roll_period
143
142
 
144
- case roll_period
145
- when :daily, :weekly, :monthly
143
+ case roll_period
144
+ when :daily, :weekly, :monthly
146
145
 
147
- ;
148
- else
146
+ ;
147
+ else
149
148
 
150
- raise ArgumentError, ":roll_period value must be one of :daily, :weekly, :monthly"
151
- end
149
+ raise ArgumentError, ":roll_period value must be one of :daily, :weekly, :monthly"
150
+ end
152
151
 
153
- logger_init_args << roll_period.to_s
154
- logger_init_args << 0
155
- end
152
+ logger_init_args << roll_period.to_s
153
+ logger_init_args << 0
154
+ end
156
155
 
157
- raise ArgumentError, ":roll_depth must be a non-negative integer" unless roll_depth.nil? || (::Integer === roll_depth && roll_depth >= 0)
158
- raise ArgumentError, ":roll_size must be a non-negative integer" unless roll_size.nil? || (::Integer === roll_size && roll_size >= 0)
156
+ raise ArgumentError, ":roll_depth must be a non-negative integer" unless roll_depth.nil? || (::Integer === roll_depth && roll_depth >= 0)
157
+ raise ArgumentError, ":roll_size must be a non-negative integer" unless roll_size.nil? || (::Integer === roll_size && roll_size >= 0)
159
158
 
160
- file_proc = lambda do
159
+ file_proc = lambda do
161
160
 
162
- @logger = ::Logger.new log_file_or_path, *logger_init_args
163
- @log_file_path = log_file_or_path.path
164
- end
161
+ @logger = ::Logger.new log_file_or_path, *logger_init_args
162
+ @log_file_path = log_file_or_path.path
163
+ end
165
164
 
166
- io_proc = lambda do
165
+ io_proc = lambda do
167
166
 
168
- @logger = ::Logger.new log_file_or_path, *logger_init_args
169
- @log_file_path = log_file_or_path.respond_to?(:path) ? log_file_or_path.path : nil
170
- end
167
+ @logger = ::Logger.new log_file_or_path, *logger_init_args
168
+ @log_file_path = log_file_or_path.respond_to?(:path) ? log_file_or_path.path : nil
169
+ end
171
170
 
172
- case log_file_or_path
173
- when nil
171
+ case log_file_or_path
172
+ when nil
174
173
 
175
- raise ArgumentError, 'log_file_or_path may not be nil'
176
- when ::IO#, ::StringIO
174
+ raise ArgumentError, 'log_file_or_path may not be nil'
175
+ when ::IO#, ::StringIO
177
176
 
178
- io_proc.call
179
- when ::File#, ::Tempfile
177
+ io_proc.call
178
+ when ::File#, ::Tempfile
180
179
 
181
- file_proc.call
182
- when ::String
180
+ file_proc.call
181
+ when ::String
183
182
 
184
- @logger = ::Logger.new log_file_or_path, *logger_init_args
185
- @log_file_path = log_file_or_path
186
- else
183
+ @logger = ::Logger.new log_file_or_path, *logger_init_args
184
+ @log_file_path = log_file_or_path
185
+ else
187
186
 
188
- ancestor_names = log_file_or_path.class.ancestors.map(&:to_s)
187
+ ancestor_names = log_file_or_path.class.ancestors.map(&:to_s)
189
188
 
190
- if false
189
+ if false
191
190
 
192
- ;
193
- elsif ancestor_names.include?('StringIO')
191
+ ;
192
+ elsif ancestor_names.include?('StringIO')
194
193
 
195
- io_proc.call
196
- elsif ancestor_names.include?('Tempfile')
194
+ io_proc.call
195
+ elsif ancestor_names.include?('Tempfile')
197
196
 
198
- file_proc.call
199
- else
197
+ file_proc.call
198
+ else
200
199
 
201
- raise TypeError, "log_file_or_path type must be one of #{::File}, #{::IO}, #{::String}, #{::StringIO}"
202
- end
203
- end
200
+ raise TypeError, "log_file_or_path type must be one of #{::File}, #{::IO}, #{::String}, #{::StringIO}"
201
+ end
202
+ end
204
203
 
205
- self
206
- end
204
+ self
205
+ end
207
206
 
208
- # The path of the underlying log file. May return +nil+ if the path
209
- # cannot be determined
210
- attr_reader :log_file_path
207
+ # The path of the underlying log file. May return +nil+ if the path
208
+ # cannot be determined
209
+ attr_reader :log_file_path
211
210
 
212
- def severity_logged? severity
211
+ def severity_logged? severity
213
212
 
214
- true
215
- end
213
+ true
214
+ end
216
215
 
217
- def log sev, t, pref, msg
216
+ def log sev, t, pref, msg
218
217
 
219
- @logger << "#{pref}#{msg}\n"
220
- end
218
+ @logger << "#{pref}#{msg}\n"
219
+ end
221
220
  end
222
221
 
223
222
 
@@ -1,4 +1,4 @@
1
-
1
+ # frozen_string_literal: true
2
2
  # ######################################################################## #
3
3
  # File: lib/pantheios/services/standard_log_service_adapter.rb
4
4
  #
@@ -6,14 +6,14 @@
6
6
  # ::Pantheios::Services::StandardLogServiceAdapter class
7
7
  #
8
8
  # Created: 18th June 2015
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
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
@@ -68,176 +68,176 @@ module Services
68
68
  # +log(severity : Object, t : Time, prefix : String|Array, msg : String)+
69
69
  class StandardLogServiceAdapter
70
70
 
71
- include ::Xqsr3::Quality::ParameterChecking
71
+ include ::Xqsr3::Quality::ParameterChecking
72
72
 
73
- STOCK_SEVS_EXT2NUM = ::Pantheios::ApplicationLayer::StockSeverityLevels::STOCK_SEVERITY_LEVEL_VALUES
73
+ STOCK_SEVS_EXT2NUM = ::Pantheios::ApplicationLayer::StockSeverityLevels::STOCK_SEVERITY_LEVEL_VALUES
74
74
 
75
- SEV_LEVELS_INT2PAIR = {
75
+ SEV_LEVELS_INT2PAIR = {
76
76
 
77
- ::Logger::DEBUG => [ :debug0, STOCK_SEVS_EXT2NUM[:debug0] ],
78
- ::Logger::WARN => [ :warning, STOCK_SEVS_EXT2NUM[:warning] ],
79
- ::Logger::ERROR => [ :failure, STOCK_SEVS_EXT2NUM[:failure] ],
80
- ::Logger::FATAL => [ :alert, STOCK_SEVS_EXT2NUM[:alert] ],
81
- ::Logger::UNKNOWN => [ :violation, STOCK_SEVS_EXT2NUM[:violation] ],
82
- }
77
+ ::Logger::DEBUG => [ :debug0, STOCK_SEVS_EXT2NUM[:debug0] ],
78
+ ::Logger::WARN => [ :warning, STOCK_SEVS_EXT2NUM[:warning] ],
79
+ ::Logger::ERROR => [ :failure, STOCK_SEVS_EXT2NUM[:failure] ],
80
+ ::Logger::FATAL => [ :alert, STOCK_SEVS_EXT2NUM[:alert] ],
81
+ ::Logger::UNKNOWN => [ :violation, STOCK_SEVS_EXT2NUM[:violation] ],
82
+ }
83
83
 
84
- SEV_LEVELS_EXT2INT = {
84
+ SEV_LEVELS_EXT2INT = {
85
85
 
86
- :trace => ::Logger::DEBUG,
87
- :benchmark => ::Logger::DEBUG,
86
+ :trace => ::Logger::DEBUG,
87
+ :benchmark => ::Logger::DEBUG,
88
88
 
89
- :debug0 => ::Logger::DEBUG,
90
- :debug1 => ::Logger::DEBUG,
91
- :debug2 => ::Logger::DEBUG,
92
- :debug3 => ::Logger::DEBUG,
93
- :debug4 => ::Logger::DEBUG,
89
+ :debug0 => ::Logger::DEBUG,
90
+ :debug1 => ::Logger::DEBUG,
91
+ :debug2 => ::Logger::DEBUG,
92
+ :debug3 => ::Logger::DEBUG,
93
+ :debug4 => ::Logger::DEBUG,
94
94
 
95
- :notice => ::Logger::INFO,
96
- :informational => ::Logger::INFO, :info => ::Logger::INFO,
95
+ :notice => ::Logger::INFO,
96
+ :informational => ::Logger::INFO, :info => ::Logger::INFO,
97
97
 
98
- :warning => ::Logger::WARN, :warn => ::Logger::WARN,
98
+ :warning => ::Logger::WARN, :warn => ::Logger::WARN,
99
99
 
100
- :failure => ::Logger::ERROR, :error => ::Logger::ERROR,
101
- :critical => ::Logger::ERROR,
100
+ :failure => ::Logger::ERROR, :error => ::Logger::ERROR,
101
+ :critical => ::Logger::ERROR,
102
102
 
103
- :alert => ::Logger::UNKNOWN,
104
- :violation => ::Logger::UNKNOWN, :emergency => ::Logger::UNKNOWN,
105
- }
103
+ :alert => ::Logger::UNKNOWN,
104
+ :violation => ::Logger::UNKNOWN, :emergency => ::Logger::UNKNOWN,
105
+ }
106
106
 
107
- SEV_LEVELS_EXT2NUM = {
107
+ SEV_LEVELS_EXT2NUM = {
108
108
 
109
- STOCK_SEVS_EXT2NUM[:trace] => ::Logger::DEBUG,
110
- STOCK_SEVS_EXT2NUM[:benchmark] => ::Logger::DEBUG,
109
+ STOCK_SEVS_EXT2NUM[:trace] => ::Logger::DEBUG,
110
+ STOCK_SEVS_EXT2NUM[:benchmark] => ::Logger::DEBUG,
111
111
 
112
- STOCK_SEVS_EXT2NUM[:debug0] => ::Logger::DEBUG,
113
- STOCK_SEVS_EXT2NUM[:debug1] => ::Logger::DEBUG,
114
- STOCK_SEVS_EXT2NUM[:debug2] => ::Logger::DEBUG,
115
- STOCK_SEVS_EXT2NUM[:debug3] => ::Logger::DEBUG,
116
- STOCK_SEVS_EXT2NUM[:debug4] => ::Logger::DEBUG,
112
+ STOCK_SEVS_EXT2NUM[:debug0] => ::Logger::DEBUG,
113
+ STOCK_SEVS_EXT2NUM[:debug1] => ::Logger::DEBUG,
114
+ STOCK_SEVS_EXT2NUM[:debug2] => ::Logger::DEBUG,
115
+ STOCK_SEVS_EXT2NUM[:debug3] => ::Logger::DEBUG,
116
+ STOCK_SEVS_EXT2NUM[:debug4] => ::Logger::DEBUG,
117
117
 
118
- STOCK_SEVS_EXT2NUM[:notice] => ::Logger::INFO,
119
- STOCK_SEVS_EXT2NUM[:informational] => ::Logger::INFO,
118
+ STOCK_SEVS_EXT2NUM[:notice] => ::Logger::INFO,
119
+ STOCK_SEVS_EXT2NUM[:informational] => ::Logger::INFO,
120
120
 
121
- STOCK_SEVS_EXT2NUM[:warning] => ::Logger::WARN,
121
+ STOCK_SEVS_EXT2NUM[:warning] => ::Logger::WARN,
122
122
 
123
- STOCK_SEVS_EXT2NUM[:failure] => ::Logger::ERROR,
124
- STOCK_SEVS_EXT2NUM[:critical] => ::Logger::ERROR,
123
+ STOCK_SEVS_EXT2NUM[:failure] => ::Logger::ERROR,
124
+ STOCK_SEVS_EXT2NUM[:critical] => ::Logger::ERROR,
125
125
 
126
- STOCK_SEVS_EXT2NUM[:alert] => ::Logger::UNKNOWN,
127
- STOCK_SEVS_EXT2NUM[:violation] => ::Logger::UNKNOWN,
128
- }
126
+ STOCK_SEVS_EXT2NUM[:alert] => ::Logger::UNKNOWN,
127
+ STOCK_SEVS_EXT2NUM[:violation] => ::Logger::UNKNOWN,
128
+ }
129
129
 
130
130
 
131
- def initialize logger, adapter_threshold = nil, **options
131
+ def initialize logger, adapter_threshold = nil, **options
132
132
 
133
- check_parameter logger, 'logger', responds_to: [ :add, :level, :level= ]
134
- check_parameter adapter_threshold, 'adapter_threshold', types: [ ::Integer, ::Symbol ], allow_nil: true
135
- format = check_option options, :format, type: ::Symbol, values: [ :default, :simple, :standard ], allow_nil: true
133
+ check_parameter logger, 'logger', responds_to: [ :add, :level, :level= ]
134
+ check_parameter adapter_threshold, 'adapter_threshold', types: [ ::Integer, ::Symbol ], allow_nil: true
135
+ format = check_option options, :format, type: ::Symbol, values: [ :default, :simple, :standard ], allow_nil: true
136
136
 
137
- @logger = logger
138
- @format = format || :default
139
- @adapter_threshold = adapter_threshold
140
- @at_value = nil
141
- @closed = false
142
- end
137
+ @logger = logger
138
+ @format = format || :default
139
+ @adapter_threshold = adapter_threshold
140
+ @at_value = nil
141
+ @closed = false
142
+ end
143
143
 
144
- # The threshold of the adapter, as expressed in a Pantheios severity
145
- # level
146
- #
147
- # NOTE: may be +nil+, in which case the decision to determine whether to
148
- # log (in the form of the +severity_logged?+ method) will be defered to
149
- # the underlying logger.
150
- attr_reader :adapter_threshold
144
+ # The threshold of the adapter, as expressed in a Pantheios severity
145
+ # level
146
+ #
147
+ # NOTE: may be +nil+, in which case the decision to determine whether to
148
+ # log (in the form of the +severity_logged?+ method) will be defered to
149
+ # the underlying logger.
150
+ attr_reader :adapter_threshold
151
151
 
152
- def adapter_threshold= threshold
152
+ def adapter_threshold= threshold
153
153
 
154
- case @adapter_threshold = threshold
155
- when nil
154
+ case @adapter_threshold = threshold
155
+ when nil
156
156
 
157
- @at_value = nil
158
- when ::Symbol
157
+ @at_value = nil
158
+ when ::Symbol
159
159
 
160
- @at_value = STOCK_SEVS_EXT2NUM[threshold]
161
- when ::Integer
160
+ @at_value = STOCK_SEVS_EXT2NUM[threshold]
161
+ when ::Integer
162
162
 
163
- @at_value = threshold
164
- else
163
+ @at_value = threshold
164
+ else
165
165
 
166
- raise ::TypeError, 'adapter_threshold must be a symbol, an integer value, or nil'
167
- end
168
- end
166
+ raise ::TypeError, 'adapter_threshold must be a symbol, an integer value, or nil'
167
+ end
168
+ end
169
169
 
170
- def close
170
+ def close
171
171
 
172
- raise "already closed" if @closed
172
+ raise "already closed" if @closed
173
173
 
174
- @logger.close
174
+ @logger.close
175
175
 
176
- @closed = true
177
- end
176
+ @closed = true
177
+ end
178
178
 
179
- def flush
179
+ def flush
180
180
 
181
- @logger.flush if @logger.respond_to? :flush
182
- end
181
+ @logger.flush if @logger.respond_to? :flush
182
+ end
183
183
 
184
- def severity_logged? severity
184
+ def severity_logged? severity
185
185
 
186
- case severity
187
- when nil
186
+ case severity
187
+ when nil
188
188
 
189
- return true
190
- when adapter_threshold
189
+ return true
190
+ when adapter_threshold
191
191
 
192
- return true
193
- when ::Symbol
192
+ return true
193
+ when ::Symbol
194
194
 
195
- sev = STOCK_SEVS_EXT2NUM[severity] || 0
196
- when ::Integer
195
+ sev = STOCK_SEVS_EXT2NUM[severity] || 0
196
+ when ::Integer
197
197
 
198
- sev = severity
199
- else
198
+ sev = severity
199
+ else
200
200
 
201
- warn "severity - '#{severity}' - of invalid type (#{severity.class}) specified to severity_logged?"
201
+ warn "severity - '#{severity}' - of invalid type (#{severity.class}) specified to severity_logged?"
202
202
 
203
- return true
204
- end
203
+ return true
204
+ end
205
205
 
206
206
 
207
- unless adapter_threshold
207
+ unless adapter_threshold
208
208
 
209
- # ask the logger
209
+ # ask the logger
210
210
 
211
- sym, val = SEV_LEVELS_INT2PAIR[@logger.level]
211
+ _unused_sym, val = SEV_LEVELS_INT2PAIR[@logger.level]
212
212
 
213
- return sev <= val
214
- end
213
+ return sev <= val
214
+ end
215
215
 
216
216
 
217
- return sev <= @at_value
218
- end
217
+ return sev <= @at_value
218
+ end
219
219
 
220
- def log severity, t, prefix, msg
220
+ def log severity, t, prefix, msg
221
221
 
222
- sev_ext = STOCK_SEVS_EXT2NUM[severity]
223
- sev_ext ||= severity if ::Integer === severity
224
- sev_int = SEV_LEVELS_EXT2NUM[sev_ext]
225
- sev_int ||= ::Logger::UNKNOWN
222
+ sev_ext = STOCK_SEVS_EXT2NUM[severity]
223
+ sev_ext ||= severity if ::Integer === severity
224
+ sev_int = SEV_LEVELS_EXT2NUM[sev_ext]
225
+ sev_int ||= ::Logger::UNKNOWN
226
226
 
227
- case @format
228
- when :default
227
+ case @format
228
+ when :default
229
229
 
230
- prog_name = ::Pantheios::Util::ProcessUtil.derive_process_name $0
230
+ prog_name = ::Pantheios::Util::ProcessUtil.derive_process_name $0
231
231
 
232
- @logger.add sev_int, msg, prog_name
233
- when :simple
232
+ @logger.add sev_int, msg, prog_name
233
+ when :simple
234
234
 
235
- @logger << msg + ?\n
236
- when :standard
235
+ @logger << msg + ?\n
236
+ when :standard
237
237
 
238
- @logger << "#{prefix}#{msg}\n"
239
- end
240
- end
238
+ @logger << "#{prefix}#{msg}\n"
239
+ end
240
+ end
241
241
  end
242
242
 
243
243
  end # module Services
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  Dir[File.join(File.dirname(__FILE__), 'services', '*log_service.rb')].each { |f| require f }
3
4