Sha256: d451979590b45d991e4eed3cc590011e1239ed70d90bce0f006f7196abe52f09

Contents?: true

Size: 1.22 KB

Versions: 1

Compression:

Stored size: 1.22 KB

Contents

# $Id: test_basic.rb 88 2008-02-08 18:47:36Z tim_pease $

require File.join(File.dirname(__FILE__), %w[.. setup])

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> #{[1,2,3,4]}\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

1 entries across 1 versions & 1 rubygems

Version Path
logging-0.6.3 test/layouts/test_basic.rb