module DICOM::Logging
This module handles logging functionality.
Logging
functionality uses the Standard library's Logger class. To properly handle progname, which inside the DICOM
module is simply “DICOM”, in all cases, we use an implementation with a proxy class.
@note For more information, please read the Standard library Logger documentation.
@example Various logger use cases:
require 'dicom' include DICOM # Logging to STDOUT with DEBUG level: DICOM.logger = Logger.new(STDOUT) DICOM.logger.level = Logger::DEBUG # Logging to a file: DICOM.logger = Logger.new('my_logfile.log') # Combine an external logger with DICOM: logger = Logger.new(STDOUT) logger.progname = "MY_APP" DICOM.logger = logger # Now you can call the logger in the following ways: DICOM.logger.info "Message" # => "DICOM: Message" DICOM.logger.info("MY_MODULE) {"Message"} # => "MY_MODULE: Message" logger.info "Message" # => "MY_APP: Message"
Public Class Methods
included(base)
click to toggle source
Inclusion hook to make the ClassMethods
available to whatever includes the Logging
module, i.e. the DICOM
module.
# File lib/dicom/general/logging.rb, line 38 def self.included(base) base.extend(ClassMethods) end
Public Instance Methods
logger()
click to toggle source
A logger object getter. Forwards the call to the logger class method of the Logging
module.
@return [ProxyLogger] the logger class variable
# File lib/dicom/general/logging.rb, line 147 def logger self.class.logger end