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.
- checksums.yaml +5 -5
- data/AUTHORS.md +21 -0
- data/CHANGES.md +337 -0
- data/CONTRIBUTING.md +36 -0
- data/EXAMPLES.md +11 -0
- data/FAQ.md +28 -0
- data/INSTALL.md +43 -0
- data/LICENSE +21 -20
- data/NEWS.md +65 -0
- data/README.md +134 -2
- data/Rakefile +21 -0
- data/SECURITY.md +23 -0
- data/TODO.md +29 -0
- data/examples/coloured_console_log_service.rb +1 -1
- data/examples/multiple_modules.md +1 -1
- data/examples/multiple_modules.rb +36 -36
- data/examples/simple_logging.md +1 -1
- data/examples/simple_logging.rb +1 -1
- data/examples/threshold_front_end.rb +1 -1
- data/lib/pantheios/api.rb +156 -155
- data/lib/pantheios/application_layer/param_name_list.rb +1 -0
- data/lib/pantheios/application_layer/stock_severity_levels.rb +110 -111
- data/lib/pantheios/application_layer.rb +6 -5
- data/lib/pantheios/core.rb +416 -415
- data/lib/pantheios/front_ends/threshold_front_end.rb +81 -81
- data/lib/pantheios/globals.rb +45 -45
- data/lib/pantheios/services/coloured_console_log_service.rb +96 -96
- data/lib/pantheios/services/common/console.rb +58 -57
- data/lib/pantheios/services/multiplexing_log_service.rb +151 -150
- data/lib/pantheios/services/null_log_service.rb +11 -11
- data/lib/pantheios/services/simple_console_log_service.rb +20 -20
- data/lib/pantheios/services/simple_file_log_service.rb +112 -113
- data/lib/pantheios/services/standard_log_service_adapter.rb +119 -119
- data/lib/pantheios/services.rb +1 -0
- data/lib/pantheios/util/process_util.rb +25 -24
- data/lib/pantheios/util/reflection_util.rb +14 -13
- data/lib/pantheios/util/thread_util.rb +50 -49
- data/lib/pantheios/util/version_util.rb +34 -33
- data/lib/pantheios/util.rb +1 -0
- data/lib/pantheios/version.rb +19 -19
- data/lib/pantheios.rb +12 -12
- data/test/performance/test_perf_simple_statements.rb +58 -58
- data/test/performance/test_perf_trace_variants.rb +43 -57
- data/test/scratch/log_rolling_by_period_daily.rb +3 -3
- data/test/scratch/log_rolling_by_size_and_depth.rb +3 -3
- data/test/scratch/log_using_blocks.rb +12 -12
- data/test/scratch/multiplexing_log_service.rb +32 -32
- data/test/unit/application_layer/tc_param_name_list.rb +13 -13
- data/test/unit/application_layer/tc_stock_severity_levels.rb +102 -102
- data/test/unit/core/tc_core_1.rb +24 -24
- data/test/unit/front_ends/tc_threshold_front_end.rb +65 -65
- data/test/unit/services/tc_multiplexing_log_service.rb +79 -79
- data/test/unit/services/tc_null_log_service.rb +42 -42
- data/test/unit/services/tc_simple_console_log_service.rb +70 -70
- data/test/unit/services/tc_simple_file_log_service.rb +146 -146
- data/test/unit/services/tc_standard_log_service_adapter.rb +94 -96
- data/test/unit/util/tc_process_util.rb +6 -6
- data/test/unit/util/tc_reflection_util.rb +20 -20
- data/test/unit/util/tc_thread_util.rb +46 -46
- data/test/unit/util/tc_version_util.rb +47 -47
- metadata +33 -12
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
|
|
2
3
|
module Pantheios
|
|
3
4
|
module Services
|
|
@@ -5,85 +6,85 @@ module Common
|
|
|
5
6
|
|
|
6
7
|
module Console
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
module Internal_
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
STDERR_ISATTY_ = $stderr.isatty
|
|
12
|
+
OS_IS_UNIX_ = %w{
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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_
|
|
21
22
|
|
|
22
|
-
|
|
23
|
+
module ColourInitialiser
|
|
23
24
|
|
|
24
|
-
|
|
25
|
+
def self.extended other
|
|
25
26
|
|
|
26
|
-
|
|
27
|
+
other::COLOURS.each do |name, value|
|
|
27
28
|
|
|
28
|
-
|
|
29
|
+
other.const_set(name.to_s.upcase, value)
|
|
29
30
|
|
|
30
|
-
|
|
31
|
+
if SHOULD_COLOURIZE_
|
|
31
32
|
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
other.define_singleton_method(name) { |s| "\x1B[#{value}m#{s}\x1B[0m" }
|
|
34
|
+
else
|
|
34
35
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
other.define_singleton_method(name) { |s| s }
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end # module ColourInitialiser
|
|
41
|
+
end # module Internal_
|
|
41
42
|
|
|
42
|
-
|
|
43
|
+
module AnsiEscapeSequences
|
|
43
44
|
|
|
44
|
-
|
|
45
|
+
module Foreground
|
|
45
46
|
|
|
46
|
-
|
|
47
|
+
COLOURS = {
|
|
47
48
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
blinking: 5,
|
|
50
|
+
bold: 1,
|
|
51
|
+
default: 39,
|
|
51
52
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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,
|
|
60
61
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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
|
+
}
|
|
70
71
|
|
|
71
|
-
|
|
72
|
-
|
|
72
|
+
extend Internal_::ColourInitialiser
|
|
73
|
+
end # module Foreground
|
|
73
74
|
|
|
74
|
-
|
|
75
|
+
module Background
|
|
75
76
|
|
|
76
|
-
|
|
77
|
+
COLOURS = Hash[Foreground::COLOURS.reject { |k, v| [ :blinking, :bold, :default ].include? k }.map { |k, v| [ k, 10 + v ] }]
|
|
77
78
|
|
|
78
|
-
|
|
79
|
-
|
|
79
|
+
extend Internal_::ColourInitialiser
|
|
80
|
+
end # module Background
|
|
80
81
|
|
|
81
|
-
|
|
82
|
+
module Special
|
|
82
83
|
|
|
83
|
-
|
|
84
|
+
# TODO
|
|
84
85
|
|
|
85
|
-
|
|
86
|
-
|
|
86
|
+
end # module Special
|
|
87
|
+
end # end AnsiEscapeSequences
|
|
87
88
|
|
|
88
89
|
end # module Console
|
|
89
90
|
end # module Common
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
2
|
# ######################################################################## #
|
|
3
3
|
# File: lib/pantheios/services/multiplexing_log_service.rb
|
|
4
4
|
#
|
|
@@ -6,14 +6,14 @@
|
|
|
6
6
|
# ::Pantheios::Services::MultiplexingLogService class
|
|
7
7
|
#
|
|
8
8
|
# Created: 14th June 2015
|
|
9
|
-
# Updated:
|
|
9
|
+
# Updated: 28th August 2026
|
|
10
10
|
#
|
|
11
|
-
# Home:
|
|
11
|
+
# Home: https://github.com/synesissoftware/Pantheios.Ruby
|
|
12
12
|
#
|
|
13
13
|
# Author: Matthew Wilson
|
|
14
14
|
#
|
|
15
|
-
# Copyright (c) 2019-
|
|
16
|
-
# Copyright (c) 2015-
|
|
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
|
-
|
|
64
|
-
|
|
63
|
+
# @!visibility private
|
|
64
|
+
module MultiplexingLogService_Internals_ # :nodoc: all
|
|
65
65
|
|
|
66
|
-
|
|
66
|
+
class ServiceManagementInfo
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
def initialize svc
|
|
69
69
|
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
@service = svc
|
|
71
|
+
end
|
|
72
72
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
attr_reader :service
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
76
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
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
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
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
|
-
|
|
112
|
-
|
|
113
|
-
|
|
111
|
+
@process_m = {}
|
|
112
|
+
@requires_prefix = nil
|
|
113
|
+
@mx = Mutex.new unless @unsync_pf
|
|
114
|
+
end
|
|
114
115
|
|
|
115
|
-
|
|
116
|
+
private
|
|
116
117
|
|
|
117
|
-
|
|
118
|
-
|
|
118
|
+
# { svc => { sev => flag } }
|
|
119
|
+
def get_tss_svc_sev_map_
|
|
119
120
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
121
|
+
sym = @tss_sym
|
|
122
|
+
tc = Thread.current
|
|
123
|
+
m = tc.thread_variable_get sym
|
|
123
124
|
|
|
124
|
-
|
|
125
|
+
unless m
|
|
125
126
|
|
|
126
|
-
|
|
127
|
-
|
|
127
|
+
tc.thread_variable_set sym, (m = {})
|
|
128
|
+
end
|
|
128
129
|
|
|
129
|
-
|
|
130
|
-
|
|
130
|
+
m
|
|
131
|
+
end
|
|
131
132
|
|
|
132
|
-
|
|
133
|
+
def svc_sev_logged_tf_ m, svc, severity
|
|
133
134
|
|
|
134
|
-
|
|
135
|
+
m[svc.object_id] ||= {}
|
|
135
136
|
|
|
136
|
-
|
|
137
|
+
unless m[svc.object_id].has_key? severity
|
|
137
138
|
|
|
138
|
-
|
|
139
|
+
r = svc.severity_logged? severity
|
|
139
140
|
|
|
140
|
-
|
|
141
|
-
|
|
141
|
+
m[svc.object_id][severity] = r
|
|
142
|
+
else
|
|
142
143
|
|
|
143
|
-
|
|
144
|
-
|
|
144
|
+
r = m[svc.object_id][severity]
|
|
145
|
+
end
|
|
145
146
|
|
|
146
|
-
|
|
147
|
-
|
|
147
|
+
r
|
|
148
|
+
end
|
|
148
149
|
|
|
149
|
-
|
|
150
|
+
def svc_sev_logged_pf_ m, svc, severity
|
|
150
151
|
|
|
151
|
-
|
|
152
|
+
m[svc.object_id] ||= {}
|
|
152
153
|
|
|
153
|
-
|
|
154
|
+
unless m[svc.object_id].has_key? severity
|
|
154
155
|
|
|
155
|
-
|
|
156
|
+
r = svc.severity_logged? severity
|
|
156
157
|
|
|
157
|
-
|
|
158
|
-
|
|
158
|
+
m[svc.object_id][severity] = r
|
|
159
|
+
else
|
|
159
160
|
|
|
160
|
-
|
|
161
|
-
|
|
161
|
+
r = m[svc.object_id][severity]
|
|
162
|
+
end
|
|
162
163
|
|
|
163
|
-
|
|
164
|
-
|
|
164
|
+
r
|
|
165
|
+
end
|
|
165
166
|
|
|
166
|
-
|
|
167
|
+
def sev_logged_pf_ m, severity
|
|
167
168
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
169
|
+
@services.any? { |smi| svc_sev_logged_pf_ m, smi.service, severity }
|
|
170
|
+
end
|
|
171
|
+
public
|
|
171
172
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
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
|
-
|
|
181
|
+
return @requires_prefix unless @requires_prefix.nil?
|
|
181
182
|
|
|
182
|
-
|
|
183
|
+
requires_prefix = false
|
|
183
184
|
|
|
184
|
-
|
|
185
|
+
@services.each do |svc|
|
|
185
186
|
|
|
186
|
-
|
|
187
|
+
if svc.respond_to? :requires_prefix?
|
|
187
188
|
|
|
188
|
-
|
|
189
|
-
|
|
189
|
+
case rp = svc.requires_prefix?
|
|
190
|
+
when nil, false
|
|
190
191
|
|
|
191
|
-
|
|
192
|
-
|
|
192
|
+
;
|
|
193
|
+
when true
|
|
193
194
|
|
|
194
|
-
|
|
195
|
-
|
|
195
|
+
requires_prefix ||= true
|
|
196
|
+
when :parts
|
|
196
197
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
198
|
+
requires_prefix = rp
|
|
199
|
+
break
|
|
200
|
+
else
|
|
200
201
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
202
|
+
warn "unrecognised return from requires_prefix? for service #{svc}: #{rp} (#{rp.class})"
|
|
203
|
+
end
|
|
204
|
+
end
|
|
205
|
+
end
|
|
205
206
|
|
|
206
|
-
|
|
207
|
-
|
|
207
|
+
@requires_prefix = requires_prefix
|
|
208
|
+
end
|
|
208
209
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
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
|
-
|
|
214
|
-
|
|
214
|
+
case @mode
|
|
215
|
+
when :process_fixed
|
|
215
216
|
|
|
216
|
-
|
|
217
|
+
if @unsync_pf
|
|
217
218
|
|
|
218
|
-
|
|
219
|
-
|
|
219
|
+
sev_logged_pf_ @process_m, severity
|
|
220
|
+
else
|
|
220
221
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
222
|
+
@mx.synchronize { sev_logged_pf_ @process_m, severity }
|
|
223
|
+
end
|
|
224
|
+
when :thread_fixed
|
|
224
225
|
|
|
225
|
-
|
|
226
|
+
m = get_tss_svc_sev_map_
|
|
226
227
|
|
|
227
|
-
|
|
228
|
+
@services.any? do |smi|
|
|
228
229
|
|
|
229
|
-
|
|
230
|
+
svc = smi.service
|
|
230
231
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
232
|
+
svc_sev_logged_tf_ m, svc, severity
|
|
233
|
+
end
|
|
234
|
+
else # :none
|
|
234
235
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
236
|
+
@services.any? { |smi| smi.service.severity_logged? severity }
|
|
237
|
+
end
|
|
238
|
+
end
|
|
238
239
|
|
|
239
|
-
|
|
240
|
+
def log sev, t, pref, msg
|
|
240
241
|
|
|
241
|
-
|
|
242
|
+
tss_m = :thread_fixed == @mode ? get_tss_svc_sev_map_ : nil
|
|
242
243
|
|
|
243
|
-
|
|
244
|
+
@services.each do |smi|
|
|
244
245
|
|
|
245
|
-
|
|
246
|
+
svc = smi.service
|
|
246
247
|
|
|
247
|
-
|
|
248
|
-
|
|
248
|
+
case @mode
|
|
249
|
+
when :process_fixed
|
|
249
250
|
|
|
250
|
-
|
|
251
|
+
if @unsync_pf
|
|
251
252
|
|
|
252
|
-
|
|
253
|
-
|
|
253
|
+
isl = svc_sev_logged_pf_ @process_m, svc, sev
|
|
254
|
+
else
|
|
254
255
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
256
|
+
isl = @mx.synchronize { svc_sev_logged_pf_ @process_m, svc, sev }
|
|
257
|
+
end
|
|
258
|
+
when :thread_fixed
|
|
258
259
|
|
|
259
|
-
|
|
260
|
+
m = tss_m
|
|
260
261
|
|
|
261
|
-
|
|
262
|
-
|
|
262
|
+
isl = svc_sev_logged_tf_ m, svc, sev
|
|
263
|
+
else # :none
|
|
263
264
|
|
|
264
|
-
|
|
265
|
-
|
|
265
|
+
isl = svc.severity_logged? sev
|
|
266
|
+
end
|
|
266
267
|
|
|
267
268
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
269
|
+
svc.log sev, t, pref, msg if isl
|
|
270
|
+
end
|
|
271
|
+
end
|
|
271
272
|
end
|
|
272
273
|
|
|
273
274
|
end # module Services
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
2
|
# ######################################################################## #
|
|
3
3
|
# File: lib/pantheios/services/null_log_service.rb
|
|
4
4
|
#
|
|
@@ -6,14 +6,14 @@
|
|
|
6
6
|
# class
|
|
7
7
|
#
|
|
8
8
|
# Created: 14th June 2015
|
|
9
|
-
# Updated:
|
|
9
|
+
# Updated: 28th August 2026
|
|
10
10
|
#
|
|
11
|
-
# Home:
|
|
11
|
+
# Home: https://github.com/synesissoftware/Pantheios.Ruby
|
|
12
12
|
#
|
|
13
13
|
# Author: Matthew Wilson
|
|
14
14
|
#
|
|
15
|
-
# Copyright (c) 2019-
|
|
16
|
-
# Copyright (c) 2015-
|
|
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
|
-
|
|
63
|
+
def severity_logged? severity
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
false
|
|
66
|
+
end
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
def log sev, t, pref, msg
|
|
69
69
|
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
;
|
|
71
|
+
end
|
|
72
72
|
end
|
|
73
73
|
|
|
74
74
|
end # module Services
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
2
|
# ######################################################################## #
|
|
3
3
|
# File: lib/pantheios/services/simple_console_log_service.rb
|
|
4
4
|
#
|
|
@@ -6,14 +6,14 @@
|
|
|
6
6
|
# ::Pantheios::Services::SimpleConsoleLogService class
|
|
7
7
|
#
|
|
8
8
|
# Created: 14th June 2015
|
|
9
|
-
# Updated:
|
|
9
|
+
# Updated: 28th August 2026
|
|
10
10
|
#
|
|
11
|
-
# Home:
|
|
11
|
+
# Home: https://github.com/synesissoftware/Pantheios.Ruby
|
|
12
12
|
#
|
|
13
13
|
# Author: Matthew Wilson
|
|
14
14
|
#
|
|
15
|
-
# Copyright (c) 2019-
|
|
16
|
-
# Copyright (c) 2015-
|
|
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
|
-
|
|
63
|
+
def severity_logged? severity
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
true
|
|
66
|
+
end
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
def log sev, t, pref, msg
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
stm = infer_stream sev
|
|
71
71
|
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
stm.puts "#{pref}#{msg}"
|
|
73
|
+
end
|
|
74
74
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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
|
-
|
|
83
|
-
|
|
82
|
+
$stderr
|
|
83
|
+
end
|
|
84
84
|
end # class SimpleConsoleLogService
|
|
85
85
|
|
|
86
86
|
end # module Services
|