Sha256: 1d99fedc523561b6c66891486f3ff197cee8b5daae4ba0088fb13bd4a2d48f25
Contents?: true
Size: 1.44 KB
Versions: 5
Compression:
Stored size: 1.44 KB
Contents
require 'rubygems' require 'bundler/setup' require 'fileutils' require 'logger' module RubyApp require 'ruby_app/mixins/delegate_mixin' class Log < ::Logger extend RubyApp::Mixins::DelegateMixin def exception(exception) self.error('-' * 80) self.error("exception=#{exception.class.inspect} #{exception.message}") self.error('-' * 80) exception.backtrace.each do |line| self.error(line) end self.error('-' * 80) end def debug_hash(hash, indent = 0) hash.each do |name, value| if value.is_a?(Hash) self.debug("#{' ' * 2 * indent}#{name.inspect}") self.debug_hash(value, indent + 1) else self.debug("#{' ' * 2 * indent}#{name.inspect} = #{value.inspect}") end end end def duration(message) start = Time.now result = yield if block_given? self.debug("#{message} duration=#{Time.now - start}s") return result end def self.get @@_log end def self.prefix(object, method) return "#{object.is_a?(Class) ? object : object.class}#{object.is_a?(Class) ? '.' : '#'}#{method}" end def self.open!(path) directory = File.dirname(path) FileUtils.mkdir_p(directory) @@_log = RubyApp::Log.new(path) end def self.close! @@_log.close if @@_log @@_log = nil end private def initialize(path) super(path) end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
RubyApp-0.0.88 | lib/ruby_app/log.rb |
RubyApp-0.0.87 | lib/ruby_app/log.rb |
RubyApp-0.0.86 | lib/ruby_app/log.rb |
RubyApp-0.0.85 | lib/ruby_app/log.rb |
RubyApp-0.0.84 | lib/ruby_app/log.rb |