Class: EaseEngine::Log::DailyRotateFile

Inherits:
RotateFile show all
Defined in:
lib/ease_engine/log.rb

Instance Attribute Summary

Attributes inherited from RotateFile

#max_size

Attributes inherited from IO

#file, #flags

Instance Method Summary collapse

Methods inherited from RotateFile

#rotate

Methods inherited from IO

#close

Constructor Details

#initialize(*args) ⇒ DailyRotateFile

Returns a new instance of DailyRotateFile.



47
48
49
50
51
# File 'lib/ease_engine/log.rb', line 47

def initialize( *args )
  super( *args )
  
  @check_time = EaseEngine::Time.new
end

Instance Method Details

#is_daily(time) ⇒ Object



59
60
61
# File 'lib/ease_engine/log.rb', line 59

def is_daily( time )
  ! @check_time.is_same_day( time ) && @max_size <= @file.size
end

#on_daily(time) ⇒ Object



63
64
65
66
# File 'lib/ease_engine/log.rb', line 63

def on_daily( time )
  rotate( sprintf( "%s_%04d%02d%02d", @file.path, @check_time.year, @check_time.month, @check_time.day ) )
  @check_time = time
end

#write(time, msg) ⇒ Object



53
54
55
56
57
# File 'lib/ease_engine/log.rb', line 53

def write( time, msg )
  on_daily( time ) if is_daily( time )
  
  super( time, msg )
end