Class: EasySuite::Logger

Inherits:
ThreadSafe show all
Defined in:
lib/easysuite/logger.rb

Overview

– Logger ++ Class to log easily.

Instance Method Summary collapse

Constructor Details

#initialize(log_dir = nil, log_file = nil) ⇒ Logger

– initialize ++



14
15
16
17
18
19
# File 'lib/easysuite/logger.rb', line 14

def initialize(log_dir = nil, log_file = nil)
  super()
  @log_dir = log_dir
  @log_file = log_file
  reset
end

Instance Method Details

#log_dirObject

– log_dir ++



33
34
35
# File 'lib/easysuite/logger.rb', line 33

def log_dir
  @log_dir || "."
end

#log_dir=(log_dir) ⇒ Object

– log_dir= ++



24
25
26
27
28
# File 'lib/easysuite/logger.rb', line 24

def log_dir=(log_dir)
  reutrn if (@log_dir == log_dir)
  @log_dir = log_dir
  reset
end

#log_fileObject

– log_file ++



49
50
51
52
53
# File 'lib/easysuite/logger.rb', line 49

def log_file
  s = @log_file || ""
  s = "common.log" if s.empty?
  Time.now.strftime(s)
end

#log_file=(log_file) ⇒ Object

– log_file= ++



40
41
42
43
44
# File 'lib/easysuite/logger.rb', line 40

def log_file=(log_file)
  return if (@log_file == log_file)
  @log_file = log_file
  reset
end

#puts(*args) ⇒ Object

– puts ++



58
59
60
61
62
63
64
65
# File 'lib/easysuite/logger.rb', line 58

def puts(*args)
  current = Time.now
  reset unless @last_time &&
    (@last_time.yday == current.yday) && (@last_time.year == current.year)
  @last_time = current
  prepare
  args.flatten.each {|arg| arg.to_s.each_line {|l| @logger.debug(l.chomp) }}
end