Module: RTP::Logging

Included in:
RTP, Plan
Defined in:
lib/rtp-connect/logging.rb

Overview

Note:

For more information, please read the Standard library Logger documentation.

This module handles logging functionality.

Logging functionality uses the Standard library’s Logger class. To properly handle progname, which inside the RTP module is simply “RTP”, in all cases, we use an implementation with a proxy class.

Examples:

Various logger use cases:

require 'rtp-connect'
include RTP

# Logging to STDOUT with DEBUG level:
RTP.logger = Logger.new(STDOUT)
RTP.logger.level = Logger::DEBUG

# Logging to a file:
RTP.logger = Logger.new('my_logfile.log')

# Combine an external logger with RTP:
logger = Logger.new(STDOUT)
logger.progname = "MY_APP"
RTP.logger = logger
# Now you can call the logger in the following ways:
RTP.logger.info "Message"               # => "RTP: Message"
RTP.logger.info("MY_MODULE) {"Message"} # => "MY_MODULE: Message"
logger.info "Message"                     # => "MY_APP: Message"

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object

Inclusion hook to make the ClassMethods available to whatever includes the Logging module, i.e. the RTP module.



38
39
40
# File 'lib/rtp-connect/logging.rb', line 38

def self.included(base)
  base.extend(ClassMethods)
end

Instance Method Details

#loggerProxyLogger

A logger object getter. Forwards the call to the logger class method of the Logging module.

Returns:

  • (ProxyLogger)

    the logger class variable



146
147
148
# File 'lib/rtp-connect/logging.rb', line 146

def logger
  self.class.logger
end