Sha256: ed7d1f7f5b997419a92c3180dc40ab0538a012a67143de6006087b9119d8f4aa
Contents?: true
Size: 648 Bytes
Versions: 7
Compression:
Stored size: 648 Bytes
Contents
require 'fileutils' module TwitterSms class Logger def initialize(filename,log_size=5) @log_size=log_size @raw_filename = filename @file = File.new(filename, "a") # 2x check mode write_intro end def log(message) @file.puts("#{Time.now.strftime("(%b %d - %H:%M:%S)")} #{message}") if `du -sm #{@raw_filename}`.split[0].to_i > @log_size #mb remake_file end end private def write_intro str = "Twitter-sms log file of messages since #{Time.now}" @file.puts(str) end def remake_file FileUtils.rm @raw_filename initialize end end end
Version data entries
7 entries across 7 versions & 1 rubygems