Sha256: 0295a749c83dbe340179c4311b515c3a5304d8605c18688a69dbae1ca2dcc0be
Contents?: true
Size: 1.06 KB
Versions: 1
Compression:
Stored size: 1.06 KB
Contents
class Cachetastic::Logger attr_accessor :options attr_accessor :cache_name def initialize(options, cache_name) self.options = options self.cache_name = cache_name self.options.each_pair do |n, opts| opts["level"] = (opts["level"] ||= "info").to_sym end end LOG_LEVELS = [:fatal, :error, :warn, :info, :debug] LOG_LEVELS.each do |level| define_method(level) do |*args| lm = "[CACHE] [#{level.to_s.upcase}]\t#{Time.now.strftime("%m/%d/%y %H:%m:%S")}" exs = [] args.each do |arg| if arg.is_a?(Exception) exs << arg continue end lm << "\t" << arg.to_s end exs.each do |ex| lm << "\n#{ex.message}\n" << ex.backtrace.join("\n") end self.options.each_pair do |n, opts| if LOG_LEVELS.index(opts["level"]) >= LOG_LEVELS.index(level) case opts["type"] when "file" File.open(opts["file"], "a") {|f| f.puts(lm)} when "console" puts lm end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
cachetastic-1.0.6 | lib/cachetastic_logger.rb |