Sha256: a75fab408babf6a72dcfc5aa1f60b12e066971839d591bf1ead76997ba24c3fe
Contents?: true
Size: 1.54 KB
Versions: 3
Compression:
Stored size: 1.54 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 duration(message) start = Time.now result = yield if block_given? self.debug("#{message} duration=#{Time.now - start}s") return result end 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 memory(message) self.debug("#{message} memory_usage=#{`ps -o rss= -p #{$$}`.to_i}") end def 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 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
RubyApp-0.0.91 | lib/ruby_app/log.rb |
RubyApp-0.0.90 | lib/ruby_app/log.rb |
RubyApp-0.0.89 | lib/ruby_app/log.rb |