Module: Wustl::Logger

Defined in:
lib/catissue/wustl/logger.rb

Overview

Logger configures the edu.wustl logger.

Class Method Summary collapse

Class Method Details

.configureObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/catissue/wustl/logger.rb', line 34

def self.configure
  # Set the configured flag. Configure only once.
  if @configured then return else @configured = true end
  # the log4j properties
  props = Java.load_properties('log4j.properties')
  
  # Ensure that the parent directory exists.
  if props then
    clt_log = props['log4j.appender.clientLog.File']
    ensure_parent_directory_exists(clt_log) if clt_log
    core_log = props['log4j.appender.catissuecoreclientLog.File']
    ensure_parent_directory_exists(core_log) if core_log
  end
  
  # The logger is configured differently depending on the caTissue version.
  log_cls = Java::edu.wustl.common.util.logger.Logger
  if log_cls.respond_to?(:configure) then
    # the caTissue 1.1.2 mechanism
    log_cls.configure("")
  else
    # the caTissue 1.2 mechanism
    cfg_cls = Java::edu.wustl.common.util.logger.LoggerConfig
    # the caTissue 1.2 work-around
    dir = clt_log ? File.dirname(clt_log) : default_log4j_config_directory
    # configure the logger
    cfg_cls.configureLogger(dir)
  end
end