Sha256: 2ba567b5612ad3916ce939f301351e462180bfd4e125e707fcf56ae1ce97a19d

Contents?: true

Size: 773 Bytes

Versions: 4

Compression:

Stored size: 773 Bytes

Contents

module DeepTest
  class Logger < ::Logger
    def initialize(*args)
      super
      hostname = Socket.gethostname
      self.formatter = proc { |severity, time, progname, msg| "[DeepTest@#{hostname}] #{time.strftime "%F %T"} #{msg}\n" }
      self.level = configured_log_level
    end

    def io_stream
      @logdev.dev
    end

    def configured_log_level
      if ENV['DEEP_TEST_LOG_LEVEL']
        Logger.const_get(ENV['DEEP_TEST_LOG_LEVEL'].upcase)
      else
        Logger::INFO
      end
    end

    Severity.constants.each do |severity|
      eval <<-end_src
        def #{severity.downcase}
          super
        rescue Exception => e
          super "\#{e.class}: \#{e} occurred logging on \#{caller[0]}", &nil
        end
      end_src
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
deep_test_pre-2.0 lib/deep_test/logger.rb
jstorimer-deep-test-2.0.0 lib/deep_test/logger.rb
jstorimer-deep-test-0.2.0 lib/deep_test/logger.rb
jstorimer-deep-test-0.1.0 lib/deep_test/logger.rb