Sha256: 1c9d61db450d930a7cd3e523e37a49d9b3c1dc9079a545603b6814e41e17af12

Contents?: true

Size: 1.16 KB

Versions: 5

Compression:

Stored size: 1.16 KB

Contents

# $Id: test_basic.rb 25 2007-01-30 20:19:12Z tim_pease $

require 'test/setup.rb'

module TestLogging
module TestLayouts

  class TestBasic < Test::Unit::TestCase
    include LoggingTestCase

    def setup
      super
      ::Logging.define_levels %w(debug info warn error fatal)
      @layout = ::Logging::Layouts::Basic.new
      @levels = ::Logging::LEVELS
    end

    def test_format
      event = ::Logging::LogEvent.new( 'ArrayLogger', @levels['info'],
                                       'log message', false)
      assert_equal " INFO  ArrayLogger : log message\n", @layout.format(event)

      event.data = [1, 2, 3, 4]
      assert_equal " INFO  ArrayLogger : <Array> 1234\n", @layout.format(event)

      event.level = @levels['debug']
      event.data = 'and another message'
      log = "DEBUG  ArrayLogger : and another message\n"
      assert_equal log, @layout.format(event)

      event.logger = 'Test'
      event.level = @levels['fatal']
      event.data = Exception.new
      log = "FATAL  Test : <Exception> Exception\n"
      assert_equal log, @layout.format(event)
    end

  end  # class TestBasic

end  # module TestLayouts
end  # module TestLogging

# EOF

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
logging-0.3.0 test/layouts/test_basic.rb
logging-0.3.1 test/layouts/test_basic.rb
logging-0.4.0 test/layouts/test_basic.rb
logging-0.5.0 test/layouts/test_basic.rb
logging-0.5.1 test/layouts/test_basic.rb