Module: DICOM::Logging

Included in:
DICOM, Anonymizer, DClient, DObject, DServer, Link, Parent
Defined in:
lib/dicom/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 DICOM module is simply “DICOM”, in all cases, we use an implementation with a proxy class.

Examples:

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"

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 DICOM module.



38
39
40
# File 'lib/dicom/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



147
148
149
# File 'lib/dicom/logging.rb', line 147

def logger
  self.class.logger
end