class Lumberjack::Device
may implement the close
and flush
methods if applicable.
This is an abstract class for logging devices. Subclasses must implement the write
method and
def cleanup_files!
def cleanup_files! if keep files = Dir.glob("#{path}.*").collect { |f| [f, File.ctime(f)] }.sort { |a, b| b.last <=> a.last }.collect { |a| a.first } if files.size > keep files[keep, files.length].each do |f| File.delete(f) end end end end
def close
-
(void)
-
def close flush end
def datetime_format
-
(String)
- The format for log timestamps.
def datetime_format end
def datetime_format=(format)
-
(void)
-
Parameters:
-
format
(String
) -- The format for log timestamps.
def datetime_format=(format) end
def do_once(file)
def do_once(file) begin file.flock(File::LOCK_EX) rescue SystemCallError # Most likely can't lock file because the stream is closed return end begin verify = begin file.lstat rescue nil end # Execute only if the file we locked is still the same one that needed to be rolled yield if verify && verify.ino == @file_inode && verify.size > 0 ensure begin file.flock(File::LOCK_UN) rescue nil end end end
def flush
-
(void)
-
def flush end
def reopen(logdev = nil)
-
(void)
-
Parameters:
-
logdev
(Object
) -- The log device to use.
def reopen(logdev = nil) flush end
def write(entry)
-
(void)
-
Parameters:
-
entry
(Lumberjack::LogEntry
) -- The entry to write.
def write(entry) raise NotImplementedError end