Class: P3libLogger

Inherits:
Object
  • Object
show all
Defined in:
lib/refx/engine/p3lib/p3lib_logger.rb

Class Method Summary collapse

Class Method Details

.log(key, val = '', type = 'info') ⇒ Object

we use the types info, error, debug, warning



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/refx/engine/p3lib/p3lib_logger.rb', line 7

def log(key, val='', type='info')

  val = '' if val.nil?

  logdir = File.expand_path('~')+"/Library/Logs/REFx4"
  logdir2 = File.expand_path('~')+"/Library/REFx4/JobsLogs/"+$REFXjobid.to_s

  logfile = logdir + '/Engines.log'
  logfile2 = logdir2 + '/engine.log'

  if(@logger.nil?) then
    @logger = Logger.new(logfile)
    @logger.level   = Logger::DEBUG
  end
  if(@logger2.nil?) then
    @logger2 = Logger.new(logfile2)
    @logger2.level   = Logger::DEBUG
  end

  if(!$debug.nil? && type=='debug')
    logstring = "#{type.upcase} - #{key}#{val==''?'':': '+val}"
    @logger.info Time.now.strftime("%b-%d-%Y %H:%M") +' '+ logstring
    @logger2.info Time.now.strftime("%b-%d-%Y %H:%M") +' '+ logstring
  elsif(type!='debug')
    logstring = "#{type.upcase} - #{key}#{val==''?'':': '+val}"
    @logger.info Time.now.strftime("%b-%d-%Y %H:%M") +' '+ logstring
    @logger2.info Time.now.strftime("%b-%d-%Y %H:%M") +' '+ logstring
  end
end