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.
Files changed (61) hide show
  1. checksums.yaml +5 -5
  2. data/AUTHORS.md +21 -0
  3. data/CHANGES.md +337 -0
  4. data/CONTRIBUTING.md +36 -0
  5. data/EXAMPLES.md +11 -0
  6. data/FAQ.md +28 -0
  7. data/INSTALL.md +43 -0
  8. data/LICENSE +21 -20
  9. data/NEWS.md +65 -0
  10. data/README.md +134 -2
  11. data/Rakefile +21 -0
  12. data/SECURITY.md +23 -0
  13. data/TODO.md +29 -0
  14. data/examples/coloured_console_log_service.rb +1 -1
  15. data/examples/multiple_modules.md +1 -1
  16. data/examples/multiple_modules.rb +36 -36
  17. data/examples/simple_logging.md +1 -1
  18. data/examples/simple_logging.rb +1 -1
  19. data/examples/threshold_front_end.rb +1 -1
  20. data/lib/pantheios/api.rb +156 -155
  21. data/lib/pantheios/application_layer/param_name_list.rb +1 -0
  22. data/lib/pantheios/application_layer/stock_severity_levels.rb +110 -111
  23. data/lib/pantheios/application_layer.rb +6 -5
  24. data/lib/pantheios/core.rb +416 -415
  25. data/lib/pantheios/front_ends/threshold_front_end.rb +81 -81
  26. data/lib/pantheios/globals.rb +45 -45
  27. data/lib/pantheios/services/coloured_console_log_service.rb +96 -96
  28. data/lib/pantheios/services/common/console.rb +58 -57
  29. data/lib/pantheios/services/multiplexing_log_service.rb +151 -150
  30. data/lib/pantheios/services/null_log_service.rb +11 -11
  31. data/lib/pantheios/services/simple_console_log_service.rb +20 -20
  32. data/lib/pantheios/services/simple_file_log_service.rb +112 -113
  33. data/lib/pantheios/services/standard_log_service_adapter.rb +119 -119
  34. data/lib/pantheios/services.rb +1 -0
  35. data/lib/pantheios/util/process_util.rb +25 -24
  36. data/lib/pantheios/util/reflection_util.rb +14 -13
  37. data/lib/pantheios/util/thread_util.rb +50 -49
  38. data/lib/pantheios/util/version_util.rb +34 -33
  39. data/lib/pantheios/util.rb +1 -0
  40. data/lib/pantheios/version.rb +19 -19
  41. data/lib/pantheios.rb +12 -12
  42. data/test/performance/test_perf_simple_statements.rb +58 -58
  43. data/test/performance/test_perf_trace_variants.rb +43 -57
  44. data/test/scratch/log_rolling_by_period_daily.rb +3 -3
  45. data/test/scratch/log_rolling_by_size_and_depth.rb +3 -3
  46. data/test/scratch/log_using_blocks.rb +12 -12
  47. data/test/scratch/multiplexing_log_service.rb +32 -32
  48. data/test/unit/application_layer/tc_param_name_list.rb +13 -13
  49. data/test/unit/application_layer/tc_stock_severity_levels.rb +102 -102
  50. data/test/unit/core/tc_core_1.rb +24 -24
  51. data/test/unit/front_ends/tc_threshold_front_end.rb +65 -65
  52. data/test/unit/services/tc_multiplexing_log_service.rb +79 -79
  53. data/test/unit/services/tc_null_log_service.rb +42 -42
  54. data/test/unit/services/tc_simple_console_log_service.rb +70 -70
  55. data/test/unit/services/tc_simple_file_log_service.rb +146 -146
  56. data/test/unit/services/tc_standard_log_service_adapter.rb +94 -96
  57. data/test/unit/util/tc_process_util.rb +6 -6
  58. data/test/unit/util/tc_reflection_util.rb +20 -20
  59. data/test/unit/util/tc_thread_util.rb +46 -46
  60. data/test/unit/util/tc_version_util.rb +47 -47
  61. metadata +33 -12
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  module Pantheios
3
4
  module Util
@@ -5,41 +6,41 @@ module Util
5
6
  # process utilities
6
7
  module ProcessUtil
7
8
 
8
- #
9
- # * *Options:*
10
- # - +:style+:: (:script, :script_basename, :script_dirname, :script_realpath, :script_stem) directs
11
- # the inference of the process name. If none specified, :script_stem is assumed
12
- def self.derive_process_name dollar0 = nil, **options
9
+ #
10
+ # * *Options:*
11
+ # - +:style+:: (:script, :script_basename, :script_dirname, :script_realpath, :script_stem) directs
12
+ # the inference of the process name. If none specified, :script_stem is assumed
13
+ def self.derive_process_name dollar0 = nil, **options
13
14
 
14
- dollar0 ||= $0
15
+ dollar0 ||= $0
15
16
 
16
- style = options[:style] || :script_stem
17
+ style = options[:style] || :script_stem
17
18
 
18
- case style
19
- when :script
19
+ case style
20
+ when :script
20
21
 
21
- dollar0
22
- when :script_basename
22
+ dollar0
23
+ when :script_basename
23
24
 
24
- File.basename(dollar0)
25
- when :script_dirname
25
+ File.basename(dollar0)
26
+ when :script_dirname
26
27
 
27
- File.basename(File.realpath(File.dirname(dollar0)))
28
- when :script_realpath
28
+ File.basename(File.realpath(File.dirname(dollar0)))
29
+ when :script_realpath
29
30
 
30
- File.realpath(File.dirname(dollar0))
31
- when :script_stem
31
+ File.realpath(File.dirname(dollar0))
32
+ when :script_stem
32
33
 
33
- bn = File.basename(dollar0)
34
+ bn = File.basename(dollar0)
34
35
 
35
- bn =~ /\.rb$/ ? $` : bn
36
- else
36
+ bn =~ /\.rb$/ ? $` : bn
37
+ else
37
38
 
38
- warn "#{self.class}##{__method__}: ignoring unrecognised type/value for ':style': '#{style}' (#{style.class})"
39
+ warn "#{self.class}##{__method__}: ignoring unrecognised type/value for ':style': '#{style}' (#{style.class})"
39
40
 
40
- dollar0
41
- end
42
- end
41
+ dollar0
42
+ end
43
+ end
43
44
 
44
45
  end # module ProcessUtil
45
46
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  module Pantheios
3
4
  module Util
@@ -5,27 +6,27 @@ module Util
5
6
  # reflection utilities
6
7
  module ReflectionUtil
7
8
 
8
- module ReflectionUtil_Constants
9
+ module ReflectionUtil_Constants
9
10
 
10
- ROOT_CLASSES = [ ::Object, ::BasicObject ]
11
- end
11
+ ROOT_CLASSES = [ ::Object, ::BasicObject ]
12
+ end
12
13
 
13
- # Obtains a list of all classes pertaining to +o+, excepting root
14
- # objects (+::Object+ and +::BaseObject+).
15
- def self.non_root_classes o
14
+ # Obtains a list of all classes pertaining to +o+, excepting root
15
+ # objects (+::Object+ and +::BaseObject+).
16
+ def self.non_root_classes o
16
17
 
17
- return [] if o.nil?
18
+ return [] if o.nil?
18
19
 
19
- return self.non_root_classes o.class unless ::Class === o
20
+ return self.non_root_classes o.class unless ::Class === o
20
21
 
21
- return [] if ReflectionUtil_Constants::ROOT_CLASSES.any? { |c| c == o }
22
+ return [] if ReflectionUtil_Constants::ROOT_CLASSES.any? { |c| c == o }
22
23
 
23
- s = o.superclass
24
+ s = o.superclass
24
25
 
25
- return [ o ] if ::Object == s
26
+ return [ o ] if ::Object == s
26
27
 
27
- [ o ] + self.non_root_classes(s)
28
- end
28
+ [ o ] + self.non_root_classes(s)
29
+ end
29
30
 
30
31
  end # module ProcessUtil
31
32
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  module Pantheios
3
4
  module Util
@@ -5,77 +6,77 @@ module Util
5
6
  # threading utilities
6
7
  module ThreadUtil
7
8
 
8
- # Creates (if necessary) and sets the given thread's +thread_name+
9
- # attribute to the given name
10
- #
11
- # === Signature
12
- #
13
- # * *Parameters:*
14
- # - +t+ [Thread, nil] The thread to be named, or +nil+ if it should
15
- # operate on the current (invoking) thread
16
- # - +name+ [String] The thread's name
17
- def self.set_thread_name t, name
9
+ # Creates (if necessary) and sets the given thread's +thread_name+
10
+ # attribute to the given name
11
+ #
12
+ # === Signature
13
+ #
14
+ # * *Parameters:*
15
+ # - +t+ [Thread, nil] The thread to be named, or +nil+ if it should
16
+ # operate on the current (invoking) thread
17
+ # - +name+ [String] The thread's name
18
+ def self.set_thread_name t, name
18
19
 
19
- t ||= Thread.current
20
+ t ||= Thread.current
20
21
 
21
- class << t; attr_accessor :thread_name; end unless t.respond_to? :thread_name
22
+ class << t; attr_accessor :thread_name; end unless t.respond_to? :thread_name
22
23
 
23
- t.thread_name = name
24
- end
24
+ t.thread_name = name
25
+ end
25
26
 
26
- # Obtains the name of the calling thread
27
- def self.get_thread_name t
27
+ # Obtains the name of the calling thread
28
+ def self.get_thread_name t
28
29
 
29
- t ||= Thread.current
30
+ t ||= Thread.current
30
31
 
31
- return t.thread_name if t.respond_to? :thread_name
32
+ return t.thread_name if t.respond_to? :thread_name
32
33
 
33
- t.to_s
34
- end
34
+ t.to_s
35
+ end
35
36
 
36
- # Inclusion module for giving the included type the +thread_name+
37
- # attribute
38
- #
39
- # If included into a thread type, or a thread instance, then
40
- module ThreadName
37
+ # Inclusion module for giving the included type the +thread_name+
38
+ # attribute
39
+ #
40
+ # If included into a thread type, or a thread instance, then
41
+ module ThreadName
41
42
 
42
- def self.included receiver
43
+ def self.included receiver
43
44
 
44
- if receiver < ::Thread
45
+ if receiver < ::Thread
45
46
 
46
- receiver.instance_eval do
47
+ receiver.instance_eval do
47
48
 
48
- define_method(:thread_name) { @thread_name || self.to_s }
49
- define_method(:thread_name=) { |name| @thread_name = name }
50
- end
51
- else
49
+ define_method(:thread_name) { defined?(@thread_name) && @thread_name || self.to_s }
50
+ define_method(:thread_name=) { |name| @thread_name = name }
51
+ end
52
+ else
52
53
 
53
- receiver.instance_eval do
54
+ receiver.instance_eval do
54
55
 
55
- define_method :thread_name do |name = (name_not_given_ = true)|
56
+ define_method :thread_name do |name = (name_not_given_ = true)|
56
57
 
57
- t = Thread.current
58
+ t = Thread.current
58
59
 
59
- has_tn = t.respond_to? :thread_name
60
+ has_tn = t.respond_to? :thread_name
60
61
 
61
- if name_not_given_
62
+ if name_not_given_
62
63
 
63
- return t.thread_name if has_tn
64
+ return t.thread_name if has_tn
64
65
 
65
- t.to_s
66
- else
66
+ t.to_s
67
+ else
67
68
 
68
- class << t; attr_accessor :thread_name; end unless has_tn
69
+ class << t; attr_accessor :thread_name; end unless has_tn
69
70
 
70
- t.thread_name = name
71
- end
72
- end
71
+ t.thread_name = name
72
+ end
73
+ end
73
74
 
74
- define_method(:thread_name=) { |name| thread_name name }
75
- end
76
- end
77
- end
78
- end
75
+ define_method(:thread_name=) { |name| thread_name name }
76
+ end
77
+ end
78
+ end
79
+ end
79
80
 
80
81
  end # module ThreadUtil
81
82
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  module Pantheios
3
4
  module Util
@@ -5,39 +6,39 @@ module Util
5
6
  # version utilities
6
7
  module VersionUtil
7
8
 
8
- # Compares two version designators and returns a spaceship comparison
9
- # result
10
- #
11
- # === Signature
12
- #
13
- # * *Parameters:*
14
- # - +lhs+ [String, Array[Integer|String]] The left-hand comparand
15
- # - +rhs+ [String, Array[Integer|String]] The right-hand comparand
16
- #
17
- # * *Returns:*
18
- # - 0 if the two version designators represent exactly the same version
19
- # - <0 if the +lhs+ version designator represents an earlier version
20
- # than the +rhs+ version designator
21
- # - >0 if the +lhs+ version designator represents a later version
22
- # than the +rhs+ version designator
23
- def self.version_compare lhs, rhs
24
-
25
- lhs = lhs.split('.') if String === lhs
26
- rhs = rhs.split('.') if String === rhs
27
-
28
- lhs = lhs.map { |n| n.to_i }
29
- rhs = rhs.map { |n| n.to_i }
30
-
31
- if lhs.size < rhs.size
32
-
33
- lhs += [ 0 ] * (rhs.size - lhs.size)
34
- else
35
-
36
- rhs += [ 0 ] * (lhs.size - rhs.size)
37
- end
38
-
39
- lhs <=> rhs
40
- end
9
+ # Compares two version designators and returns a spaceship comparison
10
+ # result
11
+ #
12
+ # === Signature
13
+ #
14
+ # * *Parameters:*
15
+ # - +lhs+ [String, Array[Integer|String]] The left-hand comparand
16
+ # - +rhs+ [String, Array[Integer|String]] The right-hand comparand
17
+ #
18
+ # * *Returns:*
19
+ # - 0 if the two version designators represent exactly the same version
20
+ # - <0 if the +lhs+ version designator represents an earlier version
21
+ # than the +rhs+ version designator
22
+ # - >0 if the +lhs+ version designator represents a later version
23
+ # than the +rhs+ version designator
24
+ def self.version_compare lhs, rhs
25
+
26
+ lhs = lhs.split('.') if String === lhs
27
+ rhs = rhs.split('.') if String === rhs
28
+
29
+ lhs = lhs.map { |n| n.to_i }
30
+ rhs = rhs.map { |n| n.to_i }
31
+
32
+ if lhs.size < rhs.size
33
+
34
+ lhs += [ 0 ] * (rhs.size - lhs.size)
35
+ else
36
+
37
+ rhs += [ 0 ] * (lhs.size - rhs.size)
38
+ end
39
+
40
+ lhs <=> rhs
41
+ end
41
42
  end # module VersionUtil
42
43
 
43
44
  end # module Util
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  require 'pantheios/util/process_util'
3
4
  require 'pantheios/util/thread_util'
@@ -1,17 +1,17 @@
1
-
1
+ # frozen_string_literal: true
2
2
  # ######################################################################## #
3
- # File: lib/pantheios/version.rb
3
+ # File: lib/pantheios/version.rb
4
4
  #
5
- # Purpose: Version for Pantheios.Ruby library
5
+ # Purpose: Version for Pantheios.Ruby library
6
6
  #
7
- # Created: 2nd April 2011
8
- # Updated: 5th June 2020
7
+ # Created: 2nd April 2011
8
+ # Updated: 30th August 2026
9
9
  #
10
- # Home: http://github.com/synesissoftware/Pantheios-Ruby
10
+ # Home: https://github.com/synesissoftware/Pantheios.Ruby
11
11
  #
12
- # Author: Matthew Wilson
12
+ # Author: Matthew Wilson
13
13
  #
14
- # Copyright (c) 2019-2020, Matthew Wilson and Synesis Information Systems
14
+ # Copyright (c) 2019-2026, Matthew Wilson and Synesis Information Systems
15
15
  # Copyright (c) 2011-2019, Matthew Wilson and Synesis Software
16
16
  # All rights reserved.
17
17
  #
@@ -50,18 +50,18 @@
50
50
 
51
51
  module Pantheios
52
52
 
53
- # Current version of the Pantheios.Ruby library
54
- VERSION = '0.22.0.2'
53
+ # Current version of the Pantheios.Ruby library
54
+ VERSION = '0.22.3'
55
55
 
56
- private
57
- VERSION_PARTS_ = VERSION.split(/[.]/).collect { |n| n.to_i } # :nodoc:
58
- public
59
- # Major version of the Pantheios.Ruby library
60
- VERSION_MAJOR = VERSION_PARTS_[0] # :nodoc:
61
- # Minor version of the Pantheios.Ruby library
62
- VERSION_MINOR = VERSION_PARTS_[1] # :nodoc:
63
- # Revision version of the Pantheios.Ruby library
64
- VERSION_REVISION = VERSION_PARTS_[2] # :nodoc:
56
+ private
57
+ VERSION_PARTS_ = VERSION.split(/[.]/).collect { |n| n.to_i } # :nodoc:
58
+ public
59
+ # Major version of the Pantheios.Ruby library
60
+ VERSION_MAJOR = VERSION_PARTS_[0] # :nodoc:
61
+ # Minor version of the Pantheios.Ruby library
62
+ VERSION_MINOR = VERSION_PARTS_[1] # :nodoc:
63
+ # Revision version of the Pantheios.Ruby library
64
+ VERSION_REVISION = VERSION_PARTS_[2] # :nodoc:
65
65
 
66
66
  end # module Pantheios
67
67
 
data/lib/pantheios.rb CHANGED
@@ -1,4 +1,4 @@
1
-
1
+ # frozen_string_literal: true
2
2
  # The main module for Pantheios
3
3
  #
4
4
  # Pantheios is both a namespace module and an inclusion module. When
@@ -19,21 +19,21 @@ require 'pantheios/version'
19
19
 
20
20
  module Pantheios
21
21
 
22
- # @!visibility private
23
- def self.included receiver # :nodoc:
22
+ # @!visibility private
23
+ def self.included receiver # :nodoc:
24
24
 
25
- if ::Pantheios::Globals.HAS_CASCADED_INCLUDES
25
+ if ::Pantheios::Globals.HAS_CASCADED_INCLUDES
26
26
 
27
- receiver.class_eval do
27
+ receiver.class_eval do
28
28
 
29
- include ::Pantheios::API
30
- include ::Pantheios::ApplicationLayer
31
- include ::Pantheios::Util
32
- end
33
- end
29
+ include ::Pantheios::API
30
+ include ::Pantheios::ApplicationLayer
31
+ include ::Pantheios::Util
32
+ end
33
+ end
34
34
 
35
- ::Pantheios::Core.register_include self, receiver
36
- end
35
+ ::Pantheios::Core.register_include self, receiver
36
+ end
37
37
 
38
38
  end # module Pantheios
39
39
 
@@ -6,7 +6,7 @@
6
6
  # Purpose: COMPLETE_ME
7
7
  #
8
8
  # Created: 22nd January 2018
9
- # Updated: 22nd January 2018
9
+ # Updated: 28th August 2026
10
10
  #
11
11
  # Author: Matthew Wilson
12
12
  #
@@ -31,102 +31,102 @@ N = 5000000
31
31
 
32
32
  def severity_logged? severity
33
33
 
34
- return false
34
+ return false
35
35
  end
36
36
 
37
37
 
38
38
  Benchmark.benchmark(Benchmark::CAPTION, 24, Benchmark::FORMAT, 'total:', 'avg:') do |r|
39
39
 
40
- totals = []
40
+ totals = []
41
41
 
42
- totals << r.report("arguments (1-arg)") do
42
+ totals << r.report("arguments (1-arg)") do
43
43
 
44
- for i in (0...N) do
44
+ N.times do
45
45
 
46
- log :notice, 'the cat in the hat.'
47
- end
48
- end
46
+ log :notice, 'the cat in the hat.'
47
+ end
48
+ end
49
49
 
50
- totals << r.report("blocks (1-arg)") do
50
+ totals << r.report("blocks (1-arg)") do
51
51
 
52
- for i in (0...N) do
52
+ N.times do
53
53
 
54
- log(:notice) { 'the cat in the hat!' }
55
- end
56
- end
54
+ log(:notice) { 'the cat in the hat!' }
55
+ end
56
+ end
57
57
 
58
- totals << r.report("args-if (1-arg)") do
58
+ totals << r.report("args-if (1-arg)") do
59
59
 
60
- for i in (0...N) do
60
+ N.times do
61
61
 
62
- log :notice, 'the cat in the hat.' if severity_logged? :notice
63
- end
64
- end
62
+ log :notice, 'the cat in the hat.' if severity_logged? :notice
63
+ end
64
+ end
65
65
 
66
66
 
67
- totals << r.report("arguments (simple)") do
67
+ totals << r.report("arguments (simple)") do
68
68
 
69
- for i in (0...N) do
69
+ N.times do
70
70
 
71
- log :notice, 'the ', 'cat ', 'in ', 'the ', 'hat.'
72
- end
73
- end
71
+ log :notice, 'the ', 'cat ', 'in ', 'the ', 'hat.'
72
+ end
73
+ end
74
74
 
75
- totals << r.report("blocks (simple)") do
75
+ totals << r.report("blocks (simple)") do
76
76
 
77
- for i in (0...N) do
77
+ N.times do
78
78
 
79
- log(:notice) { 'the ' + 'cat ' + 'in ' + 'the ' + 'hat!' }
80
- end
81
- end
79
+ log(:notice) { 'the ' + 'cat ' + 'in ' + 'the ' + 'hat!' }
80
+ end
81
+ end
82
82
 
83
- totals << r.report("args-if (simple)") do
83
+ totals << r.report("args-if (simple)") do
84
84
 
85
- for i in (0...N) do
85
+ N.times do
86
86
 
87
- log :notice, 'the ', 'cat ', 'in ', 'the ', 'hat.' if severity_logged? :notice
88
- end
89
- end
87
+ log :notice, 'the ', 'cat ', 'in ', 'the ', 'hat.' if severity_logged? :notice
88
+ end
89
+ end
90
90
 
91
91
 
92
- totals << r.report("arguments (complex)") do
92
+ totals << r.report("arguments (complex)") do
93
93
 
94
- cat = 'cat'
95
- hat = :hat
96
- t = Time.now
94
+ cat = 'cat'
95
+ hat = :hat
96
+ t = Time.now
97
97
 
98
- for i in (0...N) do
98
+ N.times do
99
99
 
100
- log :notice, "the #{cat} in the #{hat} (#{t})"
101
- end
102
- end
100
+ log :notice, "the #{cat} in the #{hat} (#{t})"
101
+ end
102
+ end
103
103
 
104
- totals << r.report("blocks (complex)") do
104
+ totals << r.report("blocks (complex)") do
105
105
 
106
- cat = 'cat'
107
- hat = :hat
108
- t = Time.now
106
+ cat = 'cat'
107
+ hat = :hat
108
+ t = Time.now
109
109
 
110
- for i in (0...N) do
110
+ N.times do
111
111
 
112
- log(:notice) { "the #{cat} in the #{hat} (#{t})" }
113
- end
114
- end
112
+ log(:notice) { "the #{cat} in the #{hat} (#{t})" }
113
+ end
114
+ end
115
115
 
116
- totals << r.report("args-if (complex)") do
116
+ totals << r.report("args-if (complex)") do
117
117
 
118
- cat = 'cat'
119
- hat = :hat
120
- t = Time.now
118
+ cat = 'cat'
119
+ hat = :hat
120
+ t = Time.now
121
121
 
122
- for i in (0...N) do
122
+ N.times do
123
123
 
124
- log :notice, "the #{cat} in the #{hat} (#{t})" if severity_logged? :notice
125
- end
126
- end
124
+ log :notice, "the #{cat} in the #{hat} (#{t})" if severity_logged? :notice
125
+ end
126
+ end
127
127
 
128
128
 
129
- [ totals.inject(:+), totals.inject(:+) / totals.size ]
129
+ [ totals.inject(:+), totals.inject(:+) / totals.size ]
130
130
  end
131
131
 
132
132