Sha256: c1c3997b2fce7afe2e0010ef77140d46832c6d2a4fc7b57ef93ba78f1869ea01

Contents?: true

Size: 897 Bytes

Versions: 14

Compression:

Stored size: 897 Bytes

Contents

require 'logger'

module RubyApp
  require 'ruby_app/application'
  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)
      self.error(exception.backtrace.join("\n"))
      self.error('-' * 80)
    end

    def self.get
      @@_log
    end

    def self.open!
      path = RubyApp::Application.options.log_path
      directory = File.dirname(path)
      Dir.mkdir(directory) unless File.exists?(directory)
      @@_log = RubyApp::Log.new(path)
      @@_log.debug("#{self}##{__method__} path=#{path.inspect}")
    end

    def self.close!
      @@_log.close if @@_log
      @@_log = nil
    end

    private

      def initialize(path)
        super(path)
      end

  end

end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
RubyApp-0.0.22 lib/ruby_app/log.rb
RubyApp-0.0.21 lib/ruby_app/log.rb
RubyApp-0.0.20 lib/ruby_app/log.rb
RubyApp-0.0.19 lib/ruby_app/log.rb
RubyApp-0.0.18 lib/ruby_app/log.rb
RubyApp-0.0.17 lib/ruby_app/log.rb
RubyApp-0.0.16 lib/ruby_app/log.rb
RubyApp-0.0.15 lib/ruby_app/log.rb
RubyApp-0.0.14 lib/ruby_app/log.rb
RubyApp-0.0.13 lib/ruby_app/log.rb
RubyApp-0.0.12 lib/ruby_app/log.rb
RubyApp-0.0.11 lib/ruby_app/log.rb
RubyApp-0.0.10 lib/ruby_app/log.rb
RubyApp-0.0.9 lib/ruby_app/log.rb