Module: RTKIT::Logging
- Included in:
- RTKIT
- Defined in:
- lib/rtkit/logging.rb
Overview
This module handles logging functionality.
Logging functionality uses the Standard library’s Logger class. To properly handle progname, which inside the RTKIT module is simply “RTKIT”, in all cases, we use an implementation with a proxy class.
Examples
require 'rtkit'
include RTKIT
# Logging to STDOUT with DEBUG level:
RTKIT.logger = Logger.new(STDOUT)
RTKIT.logger.level = Logger::DEBUG
# Logging to a file:
RTKIT.logger = Logger.new('my_logfile.log')
# Combine an external logger with RTKIT:
logger = Logger.new(STDOUT)
logger.progname = "MY_APP"
RTKIT.logger = logger
# Now you can call the logger in the following ways:
RTKIT.logger.info "Message" # => "RTKIT: Message"
RTKIT.logger.info("MY_MODULE) {"Message"} # => "MY_MODULE: Message"
logger.info "Message" # => "MY_APP: Message"
For more information, please read the Standard library Logger documentation.
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
-
.included(base) ⇒ Object
Inclusion hook to make the ClassMethods available to whatever includes the Logging module, i.e.
Instance Method Summary collapse
-
#logger ⇒ Object
A logger object getter.
Class Method Details
.included(base) ⇒ Object
Inclusion hook to make the ClassMethods available to whatever includes the Logging module, i.e. the RTKIT module.
39 40 41 |
# File 'lib/rtkit/logging.rb', line 39 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#logger ⇒ Object
A logger object getter. Forwards the call to the logger class method of the Logging module.
149 150 151 |
# File 'lib/rtkit/logging.rb', line 149 def logger self.class.logger end |