# File lib/backup/logger.rb, line 63 def truncate!(max_bytes = 500_000) log_file = File.join(Config.log_path, 'backup.log') return unless File.exist?(log_file) if File.stat(log_file).size > max_bytes FileUtils.mv(log_file, log_file + '~') File.open(log_file + '~', 'r') do |io_in| File.open(log_file, 'w') do |io_out| io_in.seek(-max_bytes, IO::SEEK_END) && io_in.gets while line = io_in.gets io_out.puts line end end end FileUtils.rm_f(log_file + '~') end end