module MediTAF::Utils::Logger
Logging Mechanism based on Logging gem
Attributes
loggers[R]
Public Class Methods
configure_logger_for(classname)
click to toggle source
@param classname [Class] the class for which to log @return [Logging::Logger]
# File lib/MediTAF/utils/logger.rb, line 32 def configure_logger_for(classname) raise LoggingConfigurationMissing, 'logging not found in configuration' unless MediTAF::Utils::Configuration['logging'] raise LoggingFilePathMissing, 'logging filepath not found in configuration' unless MediTAF::Utils::Configuration['logging']['filepath'] raise LoggingLevelMissing, 'logging level not found in configuration' unless MediTAF::Utils::Configuration['logging']['level'] config = MediTAF::Utils::Configuration['logging'] log = Logging.logger[classname] log.add_appenders( Logging.appenders.stdout('stdout', :layout => Logging.layouts.pattern(:pattern => '[%d] %-5l %c: %m\n')), Logging.appenders.file("#{config['filepath']}", :layout => Logging.layouts.pattern(:pattern => '[%d] %-5l %c: %m\n')) ) # valid levels are debug, info, warn, error, fatal log.level = config['level'].to_sym log rescue LoggingConfigurationMissing, LoggingFilePathMissing, LoggingLevelMissing => e raise e rescue => e raise LoggingConfigurationError, "Inner Exception: #{e.to_s}" end
logger_for(classname)
click to toggle source
@param classname [Class] the class for which to log @return [Logging::Logger]
# File lib/MediTAF/utils/logger.rb, line 26 def logger_for(classname) @loggers[classname] ||= configure_logger_for(classname) end
loggers()
click to toggle source
for unit testing purposes only
# File lib/MediTAF/utils/logger.rb, line 20 def loggers @loggers end
Public Instance Methods
log()
click to toggle source
@return [Logging::Logger]
# File lib/MediTAF/utils/logger.rb, line 10 def log @log ||= Logger.logger_for(self.class.name) end