Sha256: f77091bb0c4837571144d10e008308b839d7958c981a8852ac55dd0703125dd0

Contents?: true

Size: 969 Bytes

Versions: 2

Compression:

Stored size: 969 Bytes

Contents

$:.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib')
$:.unshift File.join(File.dirname(__FILE__), '..', '..', 'vendor')

require 'stringio'

require 'test/unit'
require 'glue/logger'

class TC_Logger < Test::Unit::TestCase # :nodoc: all

  def setup
    @io = StringIO.new('')
    Logger.set(Logger.new(@io))
  end

  def test_logger
    Logger.info 'hello'
    assert_equal(" INFO: hello\n", @io.string)

    # bug: Binding.of_caller thinks Logger is the caller.
    a = 14
    b = 13
#   Logger.trace 'a * b'
#   assert_equal(" INFO: hello\nDEBUG: a * b = 182\n", @io.string)
    
    @io.string = ''
    Logger.debug 'hello'
    assert_equal("DEBUG: hello\n", @io.string)

    # test logging level.
    Logger.get.level = Logger::INFO
    Logger.debug 'world'
    assert_equal("DEBUG: hello\n", @io.string)

    # bug:
    Logger.error 'Have forgotten that :)'
    
    # 
    Logger.set('hello.log')
    assert_instance_of(Logger, Logger.get)
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
glue-0.41.0 test/glue/tc_logger.rb
glue-0.40.0 test/glue/tc_logger.rb