Module: Pantheios::API
- Defined in:
- lib/pantheios/api.rb
Overview
-
timestamp t
Class Method Summary collapse
Instance Method Summary collapse
-
#log(severity, *args, &block) ⇒ Object
Logs an arbitrary set of parameters at the given severity level.
-
#log_v(severity, argv, &block) ⇒ Object
Logs an array of parameters at the given severity level.
- #prefix(t, severity) ⇒ Object
-
#prefix_elements ⇒ Object
Defines the ordered list of log-statement elements.
-
#process_id ⇒ Object
Obtains the process id.
-
#process_name ⇒ Object
Obtains the program name.
-
#severity_logged?(severity) ⇒ Boolean
Determines whether a given severity is logged.
-
#severity_string(severity) ⇒ Object
Obtains the string corresponding to the severity.
-
#thread_id ⇒ Object
Obtains the thread id.
-
#timestamp(t) ⇒ Object
Obtains a string-form of the timestamp.
-
#trace(*args, &block) ⇒ Object
Logs an arbitrary set of parameters at the Trace (:trace) level.
- #trace_b(b, &block) ⇒ Object
- #trace_blv(b, lvars, &block) ⇒ Object
-
#trace_v(argv, &block) ⇒ Object
Logs an array of parameters at the Trace (:trace) level.
-
#tracing? ⇒ Boolean
Determines whether tracing (severity == :trace) is enabled.
Class Method Details
.included(receiver) ⇒ Object
252 253 254 255 256 257 |
# File 'lib/pantheios/api.rb', line 252 def self.included receiver receiver.extend self ::Pantheios::Core.register_include self, receiver end |
Instance Method Details
#log(severity, *args, &block) ⇒ Object
Logs an arbitrary set of parameters at the given severity level
80 81 82 83 84 85 |
# File 'lib/pantheios/api.rb', line 80 def log severity, *args, &block return nil unless severity_logged? severity log_or_trace_with_block_ 1, severity, args, &block end |
#log_v(severity, argv, &block) ⇒ Object
Logs an array of parameters at the given severity level
88 89 90 91 92 93 |
# File 'lib/pantheios/api.rb', line 88 def log_v severity, argv, &block return nil unless severity_logged? severity log_or_trace_with_block_ 1, severity, argv, &block end |
#prefix(t, severity) ⇒ Object
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 |
# File 'lib/pantheios/api.rb', line 220 def prefix t, severity prefix_elements.map do |el| case el when :program_name, :process_name process_name when :process_id process_id when :severity severity_string severity when :thread_id thread_id when :timestamp t else s = ::Symbol === el ? ":#{el}" : el.to_s warn "ignoring unrecognised prefix_element '#{s}'" nil end end.join(', ') # TODO: need to do more intelligent joining end |
#prefix_elements ⇒ Object
Defines the ordered list of log-statement elements
Elements
Elements can be one of:
- +:process_name+
- +:process_id+
- +:severity+
- +:thread_id+
- +:timestamp+
This is called from prefix
170 171 172 173 |
# File 'lib/pantheios/api.rb', line 170 def prefix_elements [ :process_name, :thread_id, :timestamp, :severity ] end |
#process_id ⇒ Object
Obtains the process id
Unless overridden, returns the value provided by ::Pantheios::Core::process_id
179 180 181 182 |
# File 'lib/pantheios/api.rb', line 179 def process_id ::Pantheios::Core.process_id end |
#process_name ⇒ Object
Obtains the program name
Unless overridden, returns the value provided by ::Pantheios::Core::process_name
188 189 190 191 |
# File 'lib/pantheios/api.rb', line 188 def process_name ::Pantheios::Core.process_name end |
#severity_logged?(severity) ⇒ Boolean
Determines whether a given severity is logged
Signature
-
Parameters:
severity
-
The severity level, which should be a known log
severity symbol or an integral equivalent
-
Returns: a
truey
value if the severity should be logged; afalsey
value otherwise
143 144 145 146 |
# File 'lib/pantheios/api.rb', line 143 def severity_logged? severity ::Pantheios::Core.severity_logged? severity end |
#severity_string(severity) ⇒ Object
Obtains the string corresponding to the severity
Unless overridden, returns the value provided by ::Pantheios::Core::severity_string
197 198 199 200 |
# File 'lib/pantheios/api.rb', line 197 def severity_string severity ::Pantheios::Core.severity_string severity end |
#thread_id ⇒ Object
Obtains the thread id
Unless overridden, returns the value provided by ::Pantheios::Core::thread_id
206 207 208 209 |
# File 'lib/pantheios/api.rb', line 206 def thread_id ::Pantheios::Core.thread_id end |
#timestamp(t) ⇒ Object
Obtains a string-form of the timestamp
Unless overridden, returns the value provided by ::Pantheios::Core::timestamp
215 216 217 218 |
# File 'lib/pantheios/api.rb', line 215 def t ::Pantheios::Core. t, nil end |
#trace(*args, &block) ⇒ Object
Logs an arbitrary set of parameters at the Trace (:trace) level
96 97 98 99 100 101 |
# File 'lib/pantheios/api.rb', line 96 def trace *args, &block return nil unless tracing? trace_with_block_ 1, args, &block end |
#trace_b(b, &block) ⇒ Object
123 124 125 126 127 128 |
# File 'lib/pantheios/api.rb', line 123 def trace_b b, &block return nil unless tracing? ::Pantheios::Core.trace_v_impl(self, 1, ApplicationLayer::ParamNameList[*b.local_variables], :trace, b.local_variables.map { |lv| b.local_variable_get(lv) }, &block) end |
#trace_blv(b, lvars, &block) ⇒ Object
113 114 115 116 117 118 |
# File 'lib/pantheios/api.rb', line 113 def trace_blv b, lvars, &block return nil unless tracing? ::Pantheios::Core.trace_v_impl(self, 1, ApplicationLayer::ParamNameList[*lvars], :trace, lvars.map { |lv| b.local_variable_get(lv) }, &block) end |
#trace_v(argv, &block) ⇒ Object
Logs an array of parameters at the Trace (:trace) level
104 105 106 107 108 109 |
# File 'lib/pantheios/api.rb', line 104 def trace_v argv, &block return nil unless tracing? trace_with_block_ 1, argv, &block end |
#tracing? ⇒ Boolean
Determines whether tracing (severity == :trace) is enabled. This is used in the trace methods (trace
, trace_v
, trace_blv
, trace_b
) and therefore it may be overridden independently of severity_logged?
151 152 153 154 |
# File 'lib/pantheios/api.rb', line 151 def tracing? severity_logged? :trace end |