Method: TestingMemory.init_log4r

Defined in:
lib/testing_memory/testing_memory.rb

.init_log4rObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/testing_memory/testing_memory.rb', line 28

def init_log4r
  #init log4r
  log_path = Params['testing_log_path']
  unless log_path
    raise("pls specify testing log path through param:'testing_log_path'")
  end
  log_dir = File.dirname(log_path)
  FileUtils.mkdir_p(log_dir) unless File.exists?(log_dir)

  $testing_memory_log = Log4r::Logger.new 'BBFS testing server log'
  $testing_memory_log.trace = true
  formatter = Log4r::PatternFormatter.new(:pattern => "[%d] [%m]")
  #file setup
  file_config = {
      "filename" => Params['testing_log_path'],
      "trunc" => true
  }
  file_outputter = Log4r::FileOutputter.new("testing_log", file_config)
  file_outputter.level = Log4r::INFO
  file_outputter.formatter = formatter
  $testing_memory_log.outputters << file_outputter
end