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.
- checksums.yaml +4 -4
- data/CHANGES.md +26 -0
- data/NEWS.md +1 -0
- data/TODO.md +5 -2
- data/examples/coloured_console_log_service.rb +1 -1
- data/examples/multiple_modules.rb +36 -36
- data/examples/simple_logging.rb +1 -1
- data/examples/threshold_front_end.rb +1 -1
- data/lib/pantheios/api.rb +154 -153
- data/lib/pantheios/application_layer/stock_severity_levels.rb +108 -108
- data/lib/pantheios/application_layer.rb +5 -5
- data/lib/pantheios/core.rb +415 -414
- data/lib/pantheios/front_ends/threshold_front_end.rb +79 -79
- data/lib/pantheios/globals.rb +43 -43
- data/lib/pantheios/services/coloured_console_log_service.rb +94 -94
- data/lib/pantheios/services/common/console.rb +57 -57
- data/lib/pantheios/services/multiplexing_log_service.rb +149 -148
- data/lib/pantheios/services/null_log_service.rb +9 -9
- data/lib/pantheios/services/simple_console_log_service.rb +18 -18
- data/lib/pantheios/services/simple_file_log_service.rb +110 -111
- data/lib/pantheios/services/standard_log_service_adapter.rb +117 -117
- data/lib/pantheios/util/process_util.rb +24 -24
- data/lib/pantheios/util/reflection_util.rb +13 -13
- data/lib/pantheios/util/thread_util.rb +49 -49
- data/lib/pantheios/util/version_util.rb +33 -33
- data/lib/pantheios/version.rb +12 -12
- data/lib/pantheios.rb +11 -11
- 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 +6 -6
|
@@ -8,93 +8,93 @@ require 'test/unit'
|
|
|
8
8
|
|
|
9
9
|
class Test_FrontEnds_ThresholdFrontEnd < Test::Unit::TestCase
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
include ::Pantheios::FrontEnds
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
def test_SimpleConsoleLogService_type_exists
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
assert defined? ThresholdFrontEnd
|
|
16
|
+
end
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
def test_construct_with_invalid_parameters
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
assert_raise(::TypeError) { ThresholdFrontEnd.new('notice') }
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
assert_raise_with_message(::ArgumentError, /unknown threshold severity level.*something_else.*Symbol/) { ThresholdFrontEnd.new(:something_else) }
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
ThresholdFrontEnd.new(:notice)
|
|
25
|
+
ThresholdFrontEnd.new(:notice, value_lookup_map: Hash.new)
|
|
26
|
+
assert_raise_with_message(::TypeError, /:value_lookup_map must be.*Hash/) { ThresholdFrontEnd.new(:notice, value_lookup_map: Array.new) }
|
|
27
|
+
end
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
def test_default_construct
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
fe = ThresholdFrontEnd.new(:notice)
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
assert_equal :notice, fe.threshold
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
35
|
+
assert_true fe.severity_logged?(:violation)
|
|
36
|
+
assert_true fe.severity_logged?(:alert)
|
|
37
|
+
assert_true fe.severity_logged?(:critical)
|
|
38
|
+
assert_true fe.severity_logged?(:failure)
|
|
39
|
+
assert_true fe.severity_logged?(:warning)
|
|
40
|
+
assert_true fe.severity_logged?(:notice)
|
|
41
|
+
assert_false fe.severity_logged?(:informational)
|
|
42
|
+
assert_false fe.severity_logged?(:debug0)
|
|
43
|
+
assert_false fe.severity_logged?(:debug1)
|
|
44
|
+
assert_false fe.severity_logged?(:debug2)
|
|
45
|
+
assert_false fe.severity_logged?(:debug3)
|
|
46
|
+
assert_false fe.severity_logged?(:debug4)
|
|
47
|
+
assert_false fe.severity_logged?(:debug5)
|
|
48
|
+
assert_false fe.severity_logged?(:trace)
|
|
49
|
+
end
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
def test_default_construct_and_change_threshold
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
fe = ThresholdFrontEnd.new(:notice)
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
assert_equal :notice, fe.threshold
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
fe.threshold = :failure
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
assert_equal :failure, fe.threshold
|
|
60
60
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
61
|
+
assert_true fe.severity_logged?(:violation)
|
|
62
|
+
assert_true fe.severity_logged?(:alert)
|
|
63
|
+
assert_true fe.severity_logged?(:critical)
|
|
64
|
+
assert_true fe.severity_logged?(:failure)
|
|
65
|
+
assert_false fe.severity_logged?(:warning)
|
|
66
|
+
assert_false fe.severity_logged?(:notice)
|
|
67
|
+
assert_false fe.severity_logged?(:informational)
|
|
68
|
+
assert_false fe.severity_logged?(:debug0)
|
|
69
|
+
assert_false fe.severity_logged?(:debug1)
|
|
70
|
+
assert_false fe.severity_logged?(:debug2)
|
|
71
|
+
assert_false fe.severity_logged?(:debug3)
|
|
72
|
+
assert_false fe.severity_logged?(:debug4)
|
|
73
|
+
assert_false fe.severity_logged?(:debug5)
|
|
74
|
+
assert_false fe.severity_logged?(:trace)
|
|
75
|
+
end
|
|
76
76
|
|
|
77
|
-
|
|
77
|
+
def test_use_custom_thresholds
|
|
78
78
|
|
|
79
|
-
|
|
79
|
+
value_lookup_map = {
|
|
80
80
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
81
|
+
FATAL: 1,
|
|
82
|
+
ERROR: 2,
|
|
83
|
+
WARN: 3,
|
|
84
|
+
INFO: 4,
|
|
85
|
+
DEBUG: 5,
|
|
86
|
+
}
|
|
87
87
|
|
|
88
|
-
|
|
88
|
+
fe = ThresholdFrontEnd.new(:INFO, value_lookup_map: value_lookup_map)
|
|
89
89
|
|
|
90
|
-
|
|
90
|
+
assert_equal :INFO, fe.threshold
|
|
91
91
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
92
|
+
assert_true fe.severity_logged?(:FATAL)
|
|
93
|
+
assert_true fe.severity_logged?(:ERROR)
|
|
94
|
+
assert_true fe.severity_logged?(:WARN)
|
|
95
|
+
assert_true fe.severity_logged?(:INFO)
|
|
96
|
+
assert_false fe.severity_logged?(:DEBUG)
|
|
97
|
+
end
|
|
98
98
|
end
|
|
99
99
|
|
|
100
100
|
# ############################## end of file ############################# #
|
|
@@ -17,128 +17,128 @@ require 'stringio'
|
|
|
17
17
|
|
|
18
18
|
class Test_MultiplexingLogservice < Test::Unit::TestCase
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
include ::Pantheios::API
|
|
21
|
+
include ::Pantheios::Services
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
class ProgrammableLogService
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
def initialize name, severities
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
@name = name
|
|
28
|
+
@severities = severities
|
|
29
|
+
@items = []
|
|
30
|
+
end
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
attr_reader :name
|
|
33
|
+
attr_reader :items
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
def severity_logged? severity
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
@severities.include? severity
|
|
38
|
+
end
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
def log sev, t, pref, msg
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
@items << [ sev, t, pref, msg ]
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
def log_multiple_statements svc
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
previous, _ = Pantheios::Core.set_service svc
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
begin
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
severities = Pantheios::ApplicationLayer::StockSeverityLevels::STOCK_SEVERITY_LEVELS_PRIME
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
severities.each do |sev|
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
log sev, "a(n) #{sev} statement"
|
|
57
|
+
end
|
|
58
|
+
ensure
|
|
59
59
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
Pantheios::Core.set_service previous
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
63
|
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
def test_MultiplexingLogService_type_exists
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
assert defined? MultiplexingLogService
|
|
68
|
+
end
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
if defined?(MultiplexingLogService)
|
|
71
71
|
|
|
72
|
-
|
|
72
|
+
def test_MultiplexingLogService_type_is_a_class
|
|
73
73
|
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
assert_kind_of(::Class, MultiplexingLogService)
|
|
75
|
+
end
|
|
76
76
|
|
|
77
|
-
|
|
77
|
+
def test_MultiplexingLogService_type_has_expected_instance_methods
|
|
78
78
|
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
assert_type_has_instance_methods MultiplexingLogService, [ :severity_logged?, :log ]
|
|
80
|
+
end
|
|
81
81
|
|
|
82
|
-
|
|
82
|
+
def test_multiplex_1
|
|
83
83
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
84
|
+
svc_0 = ProgrammableLogService.new 'svc_0', Pantheios::ApplicationLayer::StockSeverityLevels::STOCK_SEVERITY_LEVELS_PRIME - [ :informational, :notice, :trace ]
|
|
85
|
+
svc_1 = ProgrammableLogService.new 'svc_1', [ :informational, :notice, :warning, :failure ]
|
|
86
|
+
svc_2 = ProgrammableLogService.new 'svc_2', [ :informational, :debug0, :debug1, :debug2, :debug3, :debug4 ]
|
|
87
87
|
|
|
88
|
-
|
|
88
|
+
svc = MultiplexingLogService.new [ svc_0, svc_1, svc_2 ]
|
|
89
89
|
|
|
90
|
-
|
|
90
|
+
log_multiple_statements svc
|
|
91
91
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
92
|
+
assert_equal 12, svc_0.items.size
|
|
93
|
+
assert_equal 4, svc_1.items.size
|
|
94
|
+
assert_equal 6, svc_2.items.size
|
|
95
|
+
end
|
|
96
96
|
|
|
97
|
-
|
|
97
|
+
def test_multiplex_2
|
|
98
98
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
svc_0 = ProgrammableLogService.new 'svc_0', Pantheios::ApplicationLayer::StockSeverityLevels::STOCK_SEVERITY_LEVELS_PRIME - [ :informational, :notice, :trace ]
|
|
100
|
+
svc_1 = ProgrammableLogService.new 'svc_1', [ :informational, :notice, :warning, :failure ]
|
|
101
|
+
svc_2 = ProgrammableLogService.new 'svc_2', [ :informational, :debug0, :debug1, :debug2, :debug3, :debug4 ]
|
|
102
102
|
|
|
103
|
-
|
|
103
|
+
svc = MultiplexingLogService.new [ svc_0, svc_1, svc_2 ], level_cache_mode: :none
|
|
104
104
|
|
|
105
|
-
|
|
105
|
+
log_multiple_statements svc
|
|
106
106
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
107
|
+
assert_equal 12, svc_0.items.size
|
|
108
|
+
assert_equal 4, svc_1.items.size
|
|
109
|
+
assert_equal 6, svc_2.items.size
|
|
110
|
+
end
|
|
111
111
|
|
|
112
|
-
|
|
112
|
+
def test_multiplex_3
|
|
113
113
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
114
|
+
svc_0 = ProgrammableLogService.new 'svc_0', Pantheios::ApplicationLayer::StockSeverityLevels::STOCK_SEVERITY_LEVELS_PRIME - [ :informational, :notice, :trace ]
|
|
115
|
+
svc_1 = ProgrammableLogService.new 'svc_1', [ :informational, :notice, :warning, :failure ]
|
|
116
|
+
svc_2 = ProgrammableLogService.new 'svc_2', [ :informational, :debug0, :debug1, :debug2, :debug3, :debug4 ]
|
|
117
117
|
|
|
118
|
-
|
|
118
|
+
svc = MultiplexingLogService.new [ svc_0, svc_1, svc_2 ], level_cache_mode: :process_fixed
|
|
119
119
|
|
|
120
|
-
|
|
120
|
+
log_multiple_statements svc
|
|
121
121
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
122
|
+
assert_equal 12, svc_0.items.size
|
|
123
|
+
assert_equal 4, svc_1.items.size
|
|
124
|
+
assert_equal 6, svc_2.items.size
|
|
125
|
+
end
|
|
126
126
|
|
|
127
|
-
|
|
127
|
+
def test_multiplex_4
|
|
128
128
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
129
|
+
svc_0 = ProgrammableLogService.new 'svc_0', Pantheios::ApplicationLayer::StockSeverityLevels::STOCK_SEVERITY_LEVELS_PRIME - [ :informational, :notice, :trace ]
|
|
130
|
+
svc_1 = ProgrammableLogService.new 'svc_1', [ :informational, :notice, :warning, :failure ]
|
|
131
|
+
svc_2 = ProgrammableLogService.new 'svc_2', [ :informational, :debug0, :debug1, :debug2, :debug3, :debug4 ]
|
|
132
132
|
|
|
133
|
-
|
|
133
|
+
svc = MultiplexingLogService.new [ svc_0, svc_1, svc_2 ], level_cache_mode: :thread_fixed
|
|
134
134
|
|
|
135
|
-
|
|
135
|
+
log_multiple_statements svc
|
|
136
136
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
137
|
+
assert_equal 12, svc_0.items.size
|
|
138
|
+
assert_equal 4, svc_1.items.size
|
|
139
|
+
assert_equal 6, svc_2.items.size
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
142
|
end
|
|
143
143
|
|
|
144
144
|
|
|
@@ -16,73 +16,73 @@ require 'stringio'
|
|
|
16
16
|
|
|
17
17
|
class Test_NullLogservice < Test::Unit::TestCase
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
include ::Pantheios::Services
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
def test_NullLogService_type_exists
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
assert defined? NullLogService
|
|
24
|
+
end
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
if defined?(NullLogService)
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
def test_NullLogService_type_is_a_class
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
assert_kind_of(::Class, NullLogService)
|
|
31
|
+
end
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
def test_NullLogService_type_has_expected_instance_methods
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
assert_type_has_instance_methods NullLogService, [ :severity_logged?, :log ]
|
|
36
|
+
end
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
def test_severity_logged_false_with_large_range_of_integers
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
svc = NullLogService.new
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
(-10000 .. 10000).each do |sev|
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
assert_false(svc.severity_logged?(sev), "severity '#{sev}' (#{sev.class}) was logged")
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
def test_severity_logged_false_with_stock_severity_levels
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
svc = NullLogService.new
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
::Pantheios::ApplicationLayer::StockSeverityLevels::STOCK_SEVERITY_LEVELS.each do |sev|
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
assert_false(svc.severity_logged?(sev), "severity '#{sev}' (#{sev.class}) was logged")
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
def test_log_does_nothing_to_standard_streams
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
prev_stdout, prev_stderr = $stdout, $stderr
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
begin
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
$stdout = StringIO.new
|
|
65
|
+
$stderr = StringIO.new
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
svc = NullLogService.new
|
|
68
|
+
t = Time.now
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
(-1000..1000).each do |sev|
|
|
71
71
|
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
svc.log sev, t, 'some-prefix', 'some-message'
|
|
73
|
+
end
|
|
74
74
|
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
stdout_s = $stdout.string
|
|
76
|
+
stderr_s = $stderr.string
|
|
77
77
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
assert_empty stdout_s, "NullLogService has written to $stdout!"
|
|
79
|
+
assert_empty stderr_s, "NullLogService has written to $stderr!"
|
|
80
|
+
ensure
|
|
81
81
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
82
|
+
$stdout, $stderr = prev_stdout, prev_stderr
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
86
|
end
|
|
87
87
|
|
|
88
88
|
|