Module: Pantheios::Core
- Defined in:
- lib/pantheios/core.rb
Class Method Summary collapse
-
.process_id ⇒ Object
Default implementation to obtain the process id.
-
.process_name ⇒ Object
Default implementation to obtain the process name.
-
.process_name=(name) ⇒ Object
Sets the process name.
-
.program_name ⇒ Object
- DEPRECATED
-
Use
process_name
.
-
.program_name=(name) ⇒ Object
- DEPRECATED
-
Use
process_name=
.
-
.register_include(includee, includer) ⇒ Object
:nodoc:.
-
.set_back_end(be) ⇒ Object
Sets the back-end used to emit the given log statement.
-
.set_front_end(fe) ⇒ Object
Sets the front-end that will be used to evaluate whether a given log statement will be logged.
-
.set_service(svc) ⇒ Object
Sets the service that will be used to evaluate whether a given log statement will be logged and to emit it.
-
.severity_logged?(severity) ⇒ Boolean
Default implementation to determine whether the given severity is logged.
-
.severity_string(severity) ⇒ Object
Obtains a string form of the given severity.
-
.thread_id ⇒ Object
Default implementation to obtain the thread_id.
-
.timestamp(t, fmt) ⇒ Object
Default implementation to obtain the timestamp according to a given format.
- .timestamp_format ⇒ Object
Class Method Details
.process_id ⇒ Object
Default implementation to obtain the process id
-
Returns:
Process.pid
382 383 384 385 |
# File 'lib/pantheios/core.rb', line 382 def self.process_id Process.pid end |
.process_name ⇒ Object
Default implementation to obtain the process name
-
Returns: The file stem of $0
NOTE: this is implemented in terms of Process_Util.derive_process_name
and the result is cached
394 395 396 397 |
# File 'lib/pantheios/core.rb', line 394 def self.process_name @process_name ||= ::Pantheios::Util::ProcessUtil.derive_process_name $0 end |
.process_name=(name) ⇒ Object
Sets the process name
-
Parameters:
name
- String
-
The (new) process name. May be
nil
, in which
case
process_name
will obtain the process name fromProcess_Util.derive_process_name
-
Returns: The previous version
NOTE: to reset the value, set to nil
413 414 415 416 417 418 |
# File 'lib/pantheios/core.rb', line 413 def self.process_name= name previous, @process_name = @process_name, name previous end |
.program_name ⇒ Object
- DEPRECATED
-
Use
process_name
400 |
# File 'lib/pantheios/core.rb', line 400 def self.program_name; self.process_name; end |
.program_name=(name) ⇒ Object
- DEPRECATED
-
Use
process_name=
421 |
# File 'lib/pantheios/core.rb', line 421 def self.program_name= name; self.process_name = name; end |
.register_include(includee, includer) ⇒ Object
:nodoc:
360 361 362 363 |
# File 'lib/pantheios/core.rb', line 360 def self.register_include includee, includer $stderr.puts "#{includee} included into #{includer}" if $DEBUG end |
.set_back_end(be) ⇒ Object
Sets the back-end used to emit the given log statement
-
Parameters:
-
be
The back-end instance. It must respond to thelog
message, or a ::TypeError will be raised. It may also respond to therequires_prefix?
message, which can be used to indicate whether a prepared prefix is required; if not present, the framework assumes that the back-end requires a prefix
-
-
Returns: The previously registered instance, or
nil
if no previous one was registered
333 334 335 336 |
# File 'lib/pantheios/core.rb', line 333 def self.set_back_end be @@state.set_back_end be end |
.set_front_end(fe) ⇒ Object
Sets the front-end that will be used to evaluate whether a given log statement will be logged
-
Parameters:
-
fe
The front-end instance. It must respond to theseverity_logged?
message, or a ::TypeError will be raised
-
-
Returns: The previously registered instance, or
nil
if no previous one was registered
316 317 318 319 |
# File 'lib/pantheios/core.rb', line 316 def self.set_front_end fe @@state.set_front_end fe end |
.set_service(svc) ⇒ Object
Sets the service that will be used to evaluate whether a given log statement will be logged and to emit it
-
Parameters:
-
svc
The service instance. It must respond to theseverity_logged?
andlog
messages, or a ::TypeError will be raised. It may also respond to therequires_prefix?
message, which can be used to indicate whether a prepared prefix is required; if not present, the framework assumes that the service (back-end) requires a prefix
-
-
Returns: An array of two elements, representing the previous front-end and previous back-end
352 353 354 355 |
# File 'lib/pantheios/core.rb', line 352 def self.set_service svc @@state.set_service svc end |
.severity_logged?(severity) ⇒ Boolean
Default implementation to determine whether the given severity is logged
-
Returns: If $DEBUG is
true
, then returnstrue
- all statements are emitted in debug mode. In normal operation, if the integral value ofseverity
is greater than that of:informational
then it returnsfalse
; otherwise it returntrue
373 374 375 376 |
# File 'lib/pantheios/core.rb', line 373 def self.severity_logged? severity @@state.severity_logged? severity end |
.severity_string(severity) ⇒ Object
Obtains a string form of the given severity
424 425 426 427 428 429 |
# File 'lib/pantheios/core.rb', line 424 def self.severity_string severity r = ApplicationLayer::StockSeverityLevels::STOCK_SEVERITY_LEVEL_STRINGS[severity] and return r severity.to_s end |
.thread_id ⇒ Object
Default implementation to obtain the thread_id
-
Returns: From the current thread either the value obtained via the attribute
thread_name
(if it responds to that) or viaobject_id
436 437 438 439 440 441 442 443 |
# File 'lib/pantheios/core.rb', line 436 def self.thread_id t = Thread.current return t.thread_name if t.respond_to? :thread_name t.object_id end |
.timestamp(t, fmt) ⇒ Object
Default implementation to obtain the timestamp according to a given format
-
Parameters:
-
t
[::Time] The time -
fmt
[::String, nil] The format to be used. Ifnil
the value obtained bytimestamp_format
is used -
Returns: A string representing the time
460 461 462 463 464 465 |
# File 'lib/pantheios/core.rb', line 460 def self. t, fmt fmt ||= self. t.strftime fmt end |
.timestamp_format ⇒ Object
445 446 447 448 |
# File 'lib/pantheios/core.rb', line 445 def self. '%Y-%m-%d %H:%M:%S.%6N' end |