pantheios-ruby 0.19.2 → 0.22.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +31 -0
  3. data/README.md +5 -0
  4. data/examples/coloured_console_log_service.rb +37 -0
  5. data/examples/multiple_modules.md +204 -0
  6. data/examples/multiple_modules.rb +132 -0
  7. data/examples/simple_logging.md +65 -0
  8. data/examples/simple_logging.rb +37 -0
  9. data/lib/pantheios.rb +3 -2
  10. data/lib/pantheios/api.rb +23 -6
  11. data/lib/pantheios/application_layer.rb +2 -1
  12. data/lib/pantheios/application_layer/param_name_list.rb +9 -0
  13. data/lib/pantheios/application_layer/stock_severity_levels.rb +99 -31
  14. data/lib/pantheios/core.rb +56 -25
  15. data/lib/pantheios/front_ends/threshold_front_end.rb +148 -0
  16. data/lib/pantheios/globals.rb +20 -9
  17. data/lib/pantheios/services/coloured_console_log_service.rb +204 -0
  18. data/lib/pantheios/services/common/console.rb +92 -0
  19. data/lib/pantheios/services/multiplexing_log_service.rb +42 -3
  20. data/lib/pantheios/services/null_log_service.rb +3 -2
  21. data/lib/pantheios/services/simple_console_log_service.rb +10 -8
  22. data/lib/pantheios/services/simple_file_log_service.rb +3 -4
  23. data/lib/pantheios/services/standard_log_service_adapter.rb +3 -2
  24. data/lib/pantheios/util/process_util.rb +3 -3
  25. data/lib/pantheios/util/reflection_util.rb +3 -0
  26. data/lib/pantheios/util/thread_util.rb +2 -0
  27. data/lib/pantheios/util/version_util.rb +1 -0
  28. data/lib/pantheios/version.rb +4 -3
  29. data/test/unit/application_layer/tc_stock_severity_levels.rb +67 -0
  30. data/test/unit/front_ends/tc_threshold_front_end.rb +102 -0
  31. data/test/unit/front_ends/ts_all.rb +12 -0
  32. data/test/unit/services/tc_multiplexing_log_service.rb +4 -4
  33. data/test/unit/services/tc_simple_console_log_service.rb +3 -3
  34. metadata +27 -21
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c08cdda0f4237044c0b2681d2b1a5cf47ff2315f
4
- data.tar.gz: b06b7ac4f43eead0c66d1253b72198ae1b63b28a
3
+ metadata.gz: ad32385bd72202625243bd53a0bb8016939ccc38
4
+ data.tar.gz: a96bedc8fa2604cf562ce2daa376ceaf929414c4
5
5
  SHA512:
6
- metadata.gz: 8650e0cad32dcb92b16e677da6e7a09def7302c52465460fe431890827d074cd11d009ba22d06f85a2f0de9b5003f902882085ffc206233dd47dda0de9e65e69
7
- data.tar.gz: 3ccbdfd84bf0b5ba7ada60754bd40e3a4361637da3f0c07e8ee225fd4fe1125c26f8bffcddbd8bcab58bd1ed37a97b1c02fd99a68a3e8eb9e2e5090e1ed5e940
6
+ metadata.gz: da221cb043bf8a6639497a913e219328e4c68abc53fc73cd76b1e80b0483a07dbecc11c5a36bb8bb2cccd5cbc5c6407c3fc3161e81a12651c46f2e6b9270aa74
7
+ data.tar.gz: 31182596ce8e65269a7ac3d64ca510d7430874208de1c81e94fce4db8722f30f52dcc0fabfe9792ee70194ab6ea2d7bea49cd739f68424be74fc5543d9eaa169
data/LICENSE ADDED
@@ -0,0 +1,31 @@
1
+ Pantheios.Ruby
2
+
3
+ Copyright (c) 2017-2019, Matthew Wilson and Synesis Software
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions are met:
8
+
9
+ * Redistributions of source code must retain the above copyright notice, this
10
+ list of conditions and the following disclaimer.
11
+
12
+ * Redistributions in binary form must reproduce the above copyright notice,
13
+ this list of conditions and the following disclaimer in the documentation
14
+ and/or other materials provided with the distribution.
15
+
16
+ * Neither the names of Pantheios or Pantheios.Ruby nor the names of the
17
+ copyright holder nor the names of its contributors may be used to endorse
18
+ or promote products derived from this software without specific prior written
19
+ permission.
20
+
21
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
22
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
+
@@ -0,0 +1,5 @@
1
+ # **Pantheios.Ruby**
2
+ Pantheios, for Ruby
3
+
4
+ T.B.C.
5
+
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift File.join(File.dirname(__FILE__), *(['..'] * 1), 'lib')
4
+
5
+ # requires (0)
6
+
7
+ require 'pantheios/globals'
8
+ require 'pantheios/services/coloured_console_log_service'
9
+
10
+ # globals
11
+
12
+ Pantheios::Globals.INITIAL_SERVICE_CLASSES = [ Pantheios::Services::ColouredConsoleLogService ]
13
+ Pantheios::Globals.MAIN_THREAD_NAME = [ Thread.current, 'main' ]
14
+ Pantheios::Globals.PROCESS_NAME = :script_stem
15
+
16
+ # requires (1)
17
+
18
+ require 'pantheios'
19
+
20
+ # includes
21
+
22
+ include ::Pantheios
23
+
24
+ # constants
25
+
26
+ LEVELS = %i{ violation alert critical failure warning notice informational debug0 debug1 debug2 debug3 debug4 debug5 benchmark }
27
+
28
+ # main
29
+
30
+ LEVELS.each do |level|
31
+
32
+ log(level, "logging level #{level}")
33
+ end
34
+
35
+ # ############################## end of file ############################# #
36
+
37
+
@@ -0,0 +1,204 @@
1
+ # Pantheios.Ruby Example - **multiple_modules**
2
+
3
+ ## Summary
4
+
5
+ Example showing application of Pantheios into multiple modules and
6
+ suppression of arbitrary severity levels specified as command line
7
+ arguments
8
+
9
+ ## Source
10
+
11
+ ```ruby
12
+ #!/usr/bin/env ruby
13
+
14
+ $:.unshift File.join(File.dirname(__FILE__), *([ '..' ] * 1), 'lib')
15
+
16
+ # ######################################
17
+ # requires
18
+
19
+ require 'pantheios'
20
+
21
+ # ######################################
22
+ # modules
23
+
24
+ module Organisation
25
+
26
+ module Helpers
27
+
28
+ include ::Pantheios
29
+
30
+ def with_trace
31
+
32
+ trace
33
+ end
34
+
35
+ def with_debug0; log(:debug0); end
36
+ def with_debug1; log(:debug1); end
37
+ def with_informational; log(:informational); end
38
+ def with_notice; log(:notice); end
39
+ def with_warning; log(:warning); end
40
+ def with_failure; log(:failure); end
41
+ def with_critical; log(:critical); end
42
+ def with_alert; log(:alert); end
43
+
44
+ def helper1
45
+
46
+ trace
47
+
48
+ with_debug0
49
+
50
+ with_notice
51
+ end
52
+
53
+ end # module Helpers
54
+
55
+ class OrgClass
56
+
57
+ include Helpers
58
+ include ::Pantheios
59
+
60
+ def initialize()
61
+
62
+ trace
63
+
64
+ log(:debug2) { 'initialised instance of OrgClass' }
65
+
66
+ helper1
67
+ end
68
+
69
+ end # class OrgClas
70
+
71
+ end # module Organisation
72
+
73
+ # ######################################
74
+ # includes
75
+
76
+ include ::Organisation::Helpers
77
+
78
+ include ::Pantheios
79
+
80
+ # ######################################
81
+ # constants
82
+
83
+ SUPPRESSED_SEVERITIES = %i{
84
+
85
+
86
+ }
87
+
88
+ # ######################################
89
+ # diagnostics
90
+
91
+ def detect_suppression argv
92
+
93
+ argv.each do |arg|
94
+
95
+ SUPPRESSED_SEVERITIES << arg.to_sym
96
+ end
97
+ end
98
+
99
+ class FrontEnd
100
+
101
+ def severity_logged? severity
102
+
103
+ case severity
104
+ when ::Symbol
105
+
106
+ !SUPPRESSED_SEVERITIES.include?(severity)
107
+ else
108
+
109
+ true
110
+ end
111
+ end
112
+ end
113
+
114
+ Pantheios::Core.set_front_end FrontEnd.new
115
+
116
+ # ######################################
117
+ # main
118
+
119
+ detect_suppression ARGV
120
+
121
+ log(:some_level)
122
+
123
+ log(:notice, 'starting up')
124
+
125
+ puts "Suppressed severities: #{SUPPRESSED_SEVERITIES}"
126
+
127
+ log(:info) { "Calling helpers" }
128
+
129
+ with_trace
130
+
131
+ with_debug0
132
+ with_debug1
133
+ helper1
134
+ with_critical
135
+ with_alert
136
+
137
+ log(:info) { "Creating instance of OrgClass" }
138
+
139
+ oc = Organisation::OrgClass.new
140
+
141
+ # ############################## end of file ############################# #
142
+
143
+ ```
144
+
145
+
146
+ ## Usage
147
+
148
+ ### No arguments
149
+
150
+ When executed as follows
151
+
152
+ ```
153
+ $ ./examples/multiple_modules.rb
154
+ ```
155
+
156
+ it gives the following output:
157
+
158
+ ```
159
+ [multiple_modules, 70123884951220, 2020-06-03 20:30:15.853720, some_level]:
160
+ [multiple_modules, 70123884951220, 2020-06-03 20:30:15.853882, Notice]: starting up
161
+ Suppressed severities: []
162
+ [multiple_modules, 70123884951220, 2020-06-03 20:30:15.853971, Informational]: Calling helpers
163
+ [multiple_modules, 70123884951220, 2020-06-03 20:30:15.854134, Trace]: ./examples/multiple_modules.rb:21: Object#with_trace()
164
+ [multiple_modules, 70123884951220, 2020-06-03 20:30:15.854200, Debug-0]:
165
+ [multiple_modules, 70123884951220, 2020-06-03 20:30:15.854255, Debug-1]:
166
+ [multiple_modules, 70123884951220, 2020-06-03 20:30:15.854333, Trace]: ./examples/multiple_modules.rb:35: Object#helper1()
167
+ [multiple_modules, 70123884951220, 2020-06-03 20:30:15.854386, Debug-0]:
168
+ [multiple_modules, 70123884951220, 2020-06-03 20:30:15.854522, Notice]:
169
+ [multiple_modules, 70123884951220, 2020-06-03 20:30:15.854582, Critical]:
170
+ [multiple_modules, 70123884951220, 2020-06-03 20:30:15.854631, Alert]:
171
+ [multiple_modules, 70123884951220, 2020-06-03 20:30:15.854684, Informational]: Creating instance of OrgClass
172
+ [multiple_modules, 70123884951220, 2020-06-03 20:30:15.854772, Trace]: ./examples/multiple_modules.rb:51: Organisation::OrgClass#initialize()
173
+ [multiple_modules, 70123884951220, 2020-06-03 20:30:15.854852, Debug-2]: initialised instance of OrgClass
174
+ [multiple_modules, 70123884951220, 2020-06-03 20:30:15.854930, Trace]: ./examples/multiple_modules.rb:35: Organisation::OrgClass#helper1()
175
+ [multiple_modules, 70123884951220, 2020-06-03 20:30:15.854985, Debug-0]:
176
+ [multiple_modules, 70123884951220, 2020-06-03 20:30:15.855035, Notice]:
177
+ ```
178
+
179
+ ### Some named suppressed levels
180
+
181
+ When executed as follows
182
+
183
+ ```
184
+ $ ./examples/multiple_modules.rb trace debug2
185
+ ```
186
+
187
+ it gives the following output:
188
+
189
+ ```
190
+ [multiple_modules, 70350289450660, 2020-06-03 20:25:49.201933, some_level]:
191
+ [multiple_modules, 70350289450660, 2020-06-03 20:25:49.202013, Notice]: starting up
192
+ Suppressed severities: [:trace, :debug2]
193
+ [multiple_modules, 70350289450660, 2020-06-03 20:25:49.202050, Informational]: Calling helpers
194
+ [multiple_modules, 70350289450660, 2020-06-03 20:25:49.202073, Debug-0]:
195
+ [multiple_modules, 70350289450660, 2020-06-03 20:25:49.202091, Debug-1]:
196
+ [multiple_modules, 70350289450660, 2020-06-03 20:25:49.202110, Debug-0]:
197
+ [multiple_modules, 70350289450660, 2020-06-03 20:25:49.202125, Notice]:
198
+ [multiple_modules, 70350289450660, 2020-06-03 20:25:49.202167, Critical]:
199
+ [multiple_modules, 70350289450660, 2020-06-03 20:25:49.202199, Alert]:
200
+ [multiple_modules, 70350289450660, 2020-06-03 20:25:49.202243, Informational]: Creating instance of OrgClass
201
+ [multiple_modules, 70350289450660, 2020-06-03 20:25:49.202269, Debug-0]:
202
+ [multiple_modules, 70350289450660, 2020-06-03 20:25:49.202286, Notice]:
203
+ ```
204
+
@@ -0,0 +1,132 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift File.join(File.dirname(__FILE__), *([ '..' ] * 1), 'lib')
4
+
5
+ # ######################################
6
+ # requires
7
+
8
+ require 'pantheios'
9
+
10
+ # ######################################
11
+ # modules
12
+
13
+ module Organisation
14
+
15
+ module Helpers
16
+
17
+ include ::Pantheios
18
+
19
+ def with_trace
20
+
21
+ trace
22
+ end
23
+
24
+ def with_debug0; log(:debug0); end
25
+ def with_debug1; log(:debug1); end
26
+ def with_informational; log(:informational); end
27
+ def with_notice; log(:notice); end
28
+ def with_warning; log(:warning); end
29
+ def with_failure; log(:failure); end
30
+ def with_critical; log(:critical); end
31
+ def with_alert; log(:alert); end
32
+
33
+ def helper1
34
+
35
+ trace
36
+
37
+ with_debug0
38
+
39
+ with_notice
40
+ end
41
+
42
+ end # module Helpers
43
+
44
+ class OrgClass
45
+
46
+ include Helpers
47
+ include ::Pantheios
48
+
49
+ def initialize()
50
+
51
+ trace
52
+
53
+ log(:debug2) { 'initialised instance of OrgClass' }
54
+
55
+ helper1
56
+ end
57
+
58
+ end # class OrgClas
59
+
60
+ end # module Organisation
61
+
62
+ # ######################################
63
+ # includes
64
+
65
+ include ::Organisation::Helpers
66
+
67
+ include ::Pantheios
68
+
69
+ # ######################################
70
+ # constants
71
+
72
+ SUPPRESSED_SEVERITIES = %i{
73
+
74
+
75
+ }
76
+
77
+ # ######################################
78
+ # diagnostics
79
+
80
+ def detect_suppression argv
81
+
82
+ argv.each do |arg|
83
+
84
+ SUPPRESSED_SEVERITIES << arg.to_sym
85
+ end
86
+ end
87
+
88
+ class FrontEnd
89
+
90
+ def severity_logged? severity
91
+
92
+ case severity
93
+ when ::Symbol
94
+
95
+ !SUPPRESSED_SEVERITIES.include?(severity)
96
+ else
97
+
98
+ true
99
+ end
100
+ end
101
+ end
102
+
103
+ Pantheios::Core.set_front_end FrontEnd.new
104
+
105
+ # ######################################
106
+ # main
107
+
108
+ detect_suppression ARGV
109
+
110
+ log(:some_level)
111
+
112
+ log(:notice, 'starting up')
113
+
114
+ puts "Suppressed severities: #{SUPPRESSED_SEVERITIES}"
115
+
116
+ log(:info) { "Calling helpers" }
117
+
118
+ with_trace
119
+
120
+ with_debug0
121
+ with_debug1
122
+ helper1
123
+ with_critical
124
+ with_alert
125
+
126
+ log(:info) { "Creating instance of OrgClass" }
127
+
128
+ oc = Organisation::OrgClass.new
129
+
130
+ # ############################## end of file ############################# #
131
+
132
+
@@ -0,0 +1,65 @@
1
+ # Pantheios.Ruby Example - **simple_logging**
2
+
3
+ ## Summary
4
+
5
+ Simple example supporting ```--help``` and ```--version```.
6
+
7
+ ## Source
8
+
9
+ ```ruby
10
+ #!/usr/bin/env ruby
11
+
12
+ $:.unshift File.join(File.dirname(__FILE__), *([ '..' ] * 1), 'lib')
13
+
14
+ # requires (0)
15
+
16
+ require 'pantheios/globals'
17
+
18
+ # globals
19
+
20
+ Pantheios::Globals.MAIN_THREAD_NAME = [ Thread.current, 'main' ]
21
+ Pantheios::Globals.PROCESS_NAME = :script_stem
22
+
23
+ # requires (1)
24
+
25
+ require 'pantheios'
26
+
27
+ # includes
28
+
29
+ include ::Pantheios
30
+
31
+ # constants
32
+
33
+ LEVELS = %i{ violation alert critical failure warning notice informational debug0 debug1 debug2 debug3 debug4 }
34
+
35
+ # main
36
+
37
+ LEVELS.each do |level|
38
+
39
+ log(level, "logging level #{level}")
40
+ end
41
+
42
+ # ############################## end of file ############################# #
43
+ ```
44
+
45
+ ## Usage
46
+
47
+ ### No arguments
48
+
49
+ When executed gives the following output:
50
+
51
+ ```
52
+ [simple_logging, main, 2019-06-05 13:18:52.517479, Violation]: logging level violation
53
+ [simple_logging, main, 2019-06-05 13:18:52.517615, Alert]: logging level alert
54
+ [simple_logging, main, 2019-06-05 13:18:52.517653, Critical]: logging level critical
55
+ [simple_logging, main, 2019-06-05 13:18:52.517681, Failure]: logging level failure
56
+ [simple_logging, main, 2019-06-05 13:18:52.517709, Warning]: logging level warning
57
+ [simple_logging, main, 2019-06-05 13:18:52.517735, Notice]: logging level notice
58
+ [simple_logging, main, 2019-06-05 13:18:52.517763, Informational]: logging level informational
59
+ [simple_logging, main, 2019-06-05 13:18:52.517789, Debug-0]: logging level debug0
60
+ [simple_logging, main, 2019-06-05 13:18:52.517837, Debug-1]: logging level debug1
61
+ [simple_logging, main, 2019-06-05 13:18:52.517876, Debug-2]: logging level debug2
62
+ [simple_logging, main, 2019-06-05 13:18:52.517905, Debug-3]: logging level debug3
63
+ [simple_logging, main, 2019-06-05 13:18:52.517931, Debug-4]: logging level debug4
64
+ ```
65
+