|
Subclass of FileOutputter that changes the log file daily. When a new day begins, a new file is created with the date included in the name.
df_out = DateFileOutputter.new('name', :dirname="/tmp", :date_pattern=>"%m-%d" )
A new logfile is created whenever the current time as formatted by the date pattern no longer matches the previous time. (This is a simple String comparison.) So, in order to change the frequency of the rollover, just alter the date pattern to match how fast the files should be generated. For instance, to generate files by the minute,
df_out.date_pattern = "%M"
This causes the following files to show up one minute apart, asuming the script starts at the 4th minute of the hour:
file_04.rb file_05.rb file_06.rb ...
The only limitation of this approach is that the precise time cannot be recorded as the smallest time interval equals the rollover period for this system.
Required files |
Classes and Modules |