Sha256: db18058cca555de6a16a16317e2d3098819dbfa41c41fd5254ebe9116d2fc45f

Contents?: true

Size: 968 Bytes

Versions: 6

Compression:

Stored size: 968 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)
      exception.backtrace.each do |line|
        self.error(line)
      end
      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.debug("#{self}##{__method__}")
      @@_log.close if @@_log
      @@_log = nil
    end

    private

      def initialize(path)
        super(path)
      end

  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
RubyApp-0.0.57 lib/ruby_app/log.rb
RubyApp-0.0.56 lib/ruby_app/log.rb
RubyApp-0.0.55 lib/ruby_app/log.rb
RubyApp-0.0.54 lib/ruby_app/log.rb
RubyApp-0.0.53 lib/ruby_app/log.rb
RubyApp-0.0.52 lib/ruby_app/log.rb