Sha256: af81096c3372d550b482a3f76e7b84595469525a9d9f51489ed82af630137704
Contents?: true
Size: 707 Bytes
Versions: 3
Compression:
Stored size: 707 Bytes
Contents
require 'logger' require 'fileutils' class Peastash class LogDevice < ::Logger::LogDevice def open_logfile(filename) super rescue Errno::EACCES stat_data = File.stat(filename) rescue nil STDERR.puts "[#{Time.now}][#{Process.pid}] Could not open #{filename} for writing, recreating it. Info: #{stat_data.inspect}" FileUtils.rm(filename) create_logfile(filename) rescue Errno::ENOENT => e require 'tempfile' temp_file = Tempfile.new([filename, '.log']) STDERR.puts "[#{Time.now}][#{Process.pid}] Could not open #{filename} for writing: #{e.message}. Data will be writen in: #{temp_file.path}" open_logfile(temp_file.path) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
peastash-0.2.9 | lib/peastash/log_device.rb |
peastash-0.2.7 | lib/peastash/log_device.rb |
peastash-0.2.6 | lib/peastash/log_device.rb |