pantheios-ruby 0.18.1 → 0.21.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/multiple_modules.md +204 -0
- data/examples/multiple_modules.rb +132 -0
- data/examples/simple_logging.md +65 -0
- data/examples/simple_logging.rb +35 -0
- data/lib/pantheios/application_layer/stock_severity_levels.rb +79 -22
- data/lib/pantheios/core.rb +9 -8
- 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/multiplexing_log_service.rb +239 -0
- data/lib/pantheios/services/null_log_service.rb +2 -2
- data/lib/pantheios/services/simple_console_log_service.rb +7 -6
- data/lib/pantheios/util/reflection_util.rb +2 -0
- data/lib/pantheios/util/thread_util.rb +1 -0
- data/lib/pantheios/version.rb +4 -3
- 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 +28 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: beccaa832a0515a050313c91e674a3804ffe4ac5
|
4
|
+
data.tar.gz: 2d1e8e82b8f7999578c9898afc94730e86e165d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06cfa816a8c31242ea15e6673064c136ccf7b1457f8ed399c165426c2515879c3f3d465aae57f302c3880bcee8b6ef7101e95c93f0526a5b0c9c6eeb521453c1
|
7
|
+
data.tar.gz: 3887176f2effa59a70304a4c8b5c8da013bf122f9d8882042955767c700b747ceea39d859d0351430fecc08ec32fabfc73f09513cf0d50c3367e22cbe58ef188
|
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
|
+
|
data/README.md
ADDED
@@ -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
|
+
|