pantheios-ruby 0.18.2 → 0.22.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +31 -0
- data/README.md +5 -0
- data/examples/coloured_console_log_service.rb +37 -0
- data/examples/multiple_modules.md +204 -0
- data/examples/multiple_modules.rb +132 -0
- data/examples/simple_logging.md +65 -0
- data/examples/simple_logging.rb +37 -0
- data/lib/pantheios/api.rb +21 -5
- data/lib/pantheios/application_layer/stock_severity_levels.rb +88 -27
- data/lib/pantheios/core.rb +30 -11
- data/lib/pantheios/front_ends/threshold_front_end.rb +135 -0
- data/lib/pantheios/globals.rb +14 -6
- data/lib/pantheios/services.rb +3 -0
- data/lib/pantheios/services/coloured_console_log_service.rb +204 -0
- data/lib/pantheios/services/common/console.rb +92 -0
- data/lib/pantheios/services/multiplexing_log_service.rb +277 -0
- data/lib/pantheios/services/null_log_service.rb +4 -3
- data/lib/pantheios/services/simple_console_log_service.rb +10 -8
- data/lib/pantheios/services/simple_file_log_service.rb +3 -2
- data/lib/pantheios/services/standard_log_service_adapter.rb +3 -2
- data/lib/pantheios/util/reflection_util.rb +2 -0
- data/lib/pantheios/util/thread_util.rb +1 -0
- data/lib/pantheios/version.rb +3 -2
- data/test/scratch/multiplexing_log_service.rb +109 -0
- data/test/unit/application_layer/tc_stock_severity_levels.rb +67 -0
- data/test/unit/front_ends/tc_threshold_front_end.rb +102 -0
- data/test/unit/front_ends/ts_all.rb +12 -0
- data/test/unit/services/tc_multiplexing_log_service.rb +144 -0
- data/test/unit/services/tc_simple_console_log_service.rb +3 -3
- metadata +24 -7
@@ -0,0 +1,12 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# executes all other tests
|
4
|
+
|
5
|
+
this_dir = File.expand_path(File.dirname(__FILE__))
|
6
|
+
|
7
|
+
# all tc_*rb in current directory
|
8
|
+
Dir[File.join(this_dir, 'tc_*rb')].each { |file| require file }
|
9
|
+
|
10
|
+
# all ts_*rb in immediate sub-directories
|
11
|
+
Dir[File.join(this_dir, '*', 'ts_*rb')].each { |file| require file }
|
12
|
+
|
@@ -0,0 +1,144 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# test/unit/services/tc_multiplexing_log_service.rb
|
4
|
+
|
5
|
+
$:.unshift File.join(File.dirname(__FILE__), '../../..', 'lib')
|
6
|
+
|
7
|
+
require 'pantheios/services/multiplexing_log_service'
|
8
|
+
|
9
|
+
require 'pantheios/api'
|
10
|
+
require 'pantheios/application_layer/stock_severity_levels'
|
11
|
+
|
12
|
+
require 'xqsr3/extensions/test/unit'
|
13
|
+
|
14
|
+
require 'test/unit'
|
15
|
+
|
16
|
+
require 'stringio'
|
17
|
+
|
18
|
+
class Test_MultiplexingLogservice < Test::Unit::TestCase
|
19
|
+
|
20
|
+
include ::Pantheios::API
|
21
|
+
include ::Pantheios::Services
|
22
|
+
|
23
|
+
class ProgrammableLogService
|
24
|
+
|
25
|
+
def initialize name, severities
|
26
|
+
|
27
|
+
@name = name
|
28
|
+
@severities = severities
|
29
|
+
@items = []
|
30
|
+
end
|
31
|
+
|
32
|
+
attr_reader :name
|
33
|
+
attr_reader :items
|
34
|
+
|
35
|
+
def severity_logged? severity
|
36
|
+
|
37
|
+
@severities.include? severity
|
38
|
+
end
|
39
|
+
|
40
|
+
def log sev, t, pref, msg
|
41
|
+
|
42
|
+
@items << [ sev, t, pref, msg ]
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def log_multiple_statements svc
|
47
|
+
|
48
|
+
previous, _ = Pantheios::Core.set_service svc
|
49
|
+
|
50
|
+
begin
|
51
|
+
|
52
|
+
severities = Pantheios::ApplicationLayer::StockSeverityLevels::STOCK_SEVERITY_LEVELS_PRIME
|
53
|
+
|
54
|
+
severities.each do |sev|
|
55
|
+
|
56
|
+
log sev, "a(n) #{sev} statement"
|
57
|
+
end
|
58
|
+
ensure
|
59
|
+
|
60
|
+
Pantheios::Core.set_service previous
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
def test_MultiplexingLogService_type_exists
|
66
|
+
|
67
|
+
assert defined? MultiplexingLogService
|
68
|
+
end
|
69
|
+
|
70
|
+
if defined?(MultiplexingLogService)
|
71
|
+
|
72
|
+
def test_MultiplexingLogService_type_is_a_class
|
73
|
+
|
74
|
+
assert_kind_of(::Class, MultiplexingLogService)
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_MultiplexingLogService_type_has_expected_instance_methods
|
78
|
+
|
79
|
+
assert_type_has_instance_methods MultiplexingLogService, [ :severity_logged?, :log ]
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_multiplex_1
|
83
|
+
|
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
|
+
|
88
|
+
svc = MultiplexingLogService.new [ svc_0, svc_1, svc_2 ]
|
89
|
+
|
90
|
+
log_multiple_statements svc
|
91
|
+
|
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
|
+
|
97
|
+
def test_multiplex_2
|
98
|
+
|
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
|
+
|
103
|
+
svc = MultiplexingLogService.new [ svc_0, svc_1, svc_2 ], level_cache_mode: :none
|
104
|
+
|
105
|
+
log_multiple_statements svc
|
106
|
+
|
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
|
+
|
112
|
+
def test_multiplex_3
|
113
|
+
|
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
|
+
|
118
|
+
svc = MultiplexingLogService.new [ svc_0, svc_1, svc_2 ], level_cache_mode: :process_fixed
|
119
|
+
|
120
|
+
log_multiple_statements svc
|
121
|
+
|
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
|
+
|
127
|
+
def test_multiplex_4
|
128
|
+
|
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
|
+
|
133
|
+
svc = MultiplexingLogService.new [ svc_0, svc_1, svc_2 ], level_cache_mode: :thread_fixed
|
134
|
+
|
135
|
+
log_multiple_statements svc
|
136
|
+
|
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
|
+
end
|
143
|
+
|
144
|
+
|
@@ -96,7 +96,7 @@ class Test_SimpleConsoleLogservice < Test::Unit::TestCase
|
|
96
96
|
stdout_s = $stdout.string
|
97
97
|
stderr_s = $stderr.string
|
98
98
|
|
99
|
-
|
99
|
+
assert_empty stdout_s, "SimpleConsoleLogService has written to $stdout!"
|
100
100
|
assert_not_empty stderr_s, "SimpleConsoleLogService has not written to $stderr!"
|
101
101
|
ensure
|
102
102
|
|
@@ -123,8 +123,8 @@ class Test_SimpleConsoleLogservice < Test::Unit::TestCase
|
|
123
123
|
|
124
124
|
r = self.class.log_and_get_streams sev, 'msg'
|
125
125
|
|
126
|
-
|
127
|
-
|
126
|
+
assert_empty r[0], "SimpleConsoleLogService wrote to $stdout for severity #{sev}"
|
127
|
+
assert_not_empty r[1], "SimpleConsoleLogService failed to write to $stderr for severity #{sev}"
|
128
128
|
end
|
129
129
|
end
|
130
130
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pantheios-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.22.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Wilson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-06-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: xqsr3
|
@@ -16,28 +16,41 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0.
|
19
|
+
version: '0.36'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0.
|
27
|
-
description:
|
28
|
-
|
26
|
+
version: '0.36'
|
27
|
+
description: 'A Ruby version of the popular C++ (and .NET) logging API library
|
28
|
+
|
29
|
+
'
|
29
30
|
email: matthew@synesis.com.au
|
30
31
|
executables: []
|
31
32
|
extensions: []
|
32
33
|
extra_rdoc_files: []
|
33
34
|
files:
|
35
|
+
- LICENSE
|
36
|
+
- README.md
|
37
|
+
- examples/coloured_console_log_service.rb
|
38
|
+
- examples/multiple_modules.md
|
39
|
+
- examples/multiple_modules.rb
|
40
|
+
- examples/simple_logging.md
|
41
|
+
- examples/simple_logging.rb
|
34
42
|
- lib/pantheios.rb
|
35
43
|
- lib/pantheios/api.rb
|
36
44
|
- lib/pantheios/application_layer.rb
|
37
45
|
- lib/pantheios/application_layer/param_name_list.rb
|
38
46
|
- lib/pantheios/application_layer/stock_severity_levels.rb
|
39
47
|
- lib/pantheios/core.rb
|
48
|
+
- lib/pantheios/front_ends/threshold_front_end.rb
|
40
49
|
- lib/pantheios/globals.rb
|
50
|
+
- lib/pantheios/services.rb
|
51
|
+
- lib/pantheios/services/coloured_console_log_service.rb
|
52
|
+
- lib/pantheios/services/common/console.rb
|
53
|
+
- lib/pantheios/services/multiplexing_log_service.rb
|
41
54
|
- lib/pantheios/services/null_log_service.rb
|
42
55
|
- lib/pantheios/services/simple_console_log_service.rb
|
43
56
|
- lib/pantheios/services/simple_file_log_service.rb
|
@@ -54,11 +67,15 @@ files:
|
|
54
67
|
- test/scratch/log_rolling_by_period_daily.rb
|
55
68
|
- test/scratch/log_rolling_by_size_and_depth.rb
|
56
69
|
- test/scratch/log_using_blocks.rb
|
70
|
+
- test/scratch/multiplexing_log_service.rb
|
57
71
|
- test/unit/application_layer/tc_param_name_list.rb
|
58
72
|
- test/unit/application_layer/tc_stock_severity_levels.rb
|
59
73
|
- test/unit/application_layer/ts_all.rb
|
60
74
|
- test/unit/core/tc_core_1.rb
|
61
75
|
- test/unit/core/ts_all.rb
|
76
|
+
- test/unit/front_ends/tc_threshold_front_end.rb
|
77
|
+
- test/unit/front_ends/ts_all.rb
|
78
|
+
- test/unit/services/tc_multiplexing_log_service.rb
|
62
79
|
- test/unit/services/tc_null_log_service.rb
|
63
80
|
- test/unit/services/tc_simple_console_log_service.rb
|
64
81
|
- test/unit/services/tc_simple_file_log_service.rb
|
@@ -90,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
107
|
version: '0'
|
91
108
|
requirements: []
|
92
109
|
rubyforge_project:
|
93
|
-
rubygems_version: 2.2.
|
110
|
+
rubygems_version: 2.5.2.3
|
94
111
|
signing_key:
|
95
112
|
specification_version: 4
|
96
113
|
summary: Pantheios.Ruby
|