Sha256: 1c3b02a710eba98bb92c198eabb4bef95b89bd95b98c62c3febf87865ab736b2

Contents?: true

Size: 1.61 KB

Versions: 11

Compression:

Stored size: 1.61 KB

Contents

require File.expand_path('setup', File.dirname(__FILE__))

module TestLogging

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

    def setup
      super

      @appender = EventAppender.new('test')
      @logger = ::Logging::Logger['TestLogger']
      @logger.add_appenders @appender

      @logger.info 'message 1'
      @event = @appender.event
    end

    def test_data
      assert_equal 'message 1', @event.data
    end

    def test_data_eq
      @event.data = 'message 2'
      assert_equal 'message 2', @event.data
    end

    def test_file
      assert_equal '', @event.file

      @logger.caller_tracing = true
      @logger.warn 'warning message'
      assert_match %r/test_log_event.rb\z/, @appender.event.file
    end

    def test_level
      assert_equal 1, @event.level
    end

    def test_level_eq
      @event.level = 3
      assert_equal 3, @event.level
    end

    def test_line
      assert_equal '', @event.file

      @logger.caller_tracing = true
      @logger.error 'error message'
      assert_equal __LINE__-1, @appender.event.line
    end

    def test_logger
      assert_equal 'TestLogger', @event.logger
    end

    def test_logger_eq
      @event.logger = 'MyLogger'
      assert_equal 'MyLogger', @event.logger
    end

    def test_method
      assert_equal '', @event.file

      @logger.caller_tracing = true
      @logger.debug 'debug message'
      assert_equal 'test_method', @appender.event.method
    end

  end  # class TestLogEvent

  class EventAppender < ::Logging::Appender
    attr_reader :event
    def append( event ) @event = event end
  end

end  # module TestLogging

Version data entries

11 entries across 11 versions & 3 rubygems

Version Path
vagrant-unbundled-1.9.1.1 vendor/bundle/ruby/2.4.0/gems/logging-2.1.0/test/test_log_event.rb
vagrant-compose-yaml-0.1.3 vendor/bundle/ruby/2.2.0/gems/logging-2.1.0/test/test_log_event.rb
vagrant-compose-yaml-0.1.2 vendor/bundle/ruby/2.2.0/gems/logging-2.1.0/test/test_log_event.rb
vagrant-compose-yaml-0.1.1 vendor/bundle/ruby/2.2.0/gems/logging-2.1.0/test/test_log_event.rb
vagrant-compose-yaml-0.1.0 vendor/bundle/ruby/2.2.0/gems/logging-2.1.0/test/test_log_event.rb
vagrant-unbundled-1.8.5.2 vendor/bundle/ruby/2.3.0/gems/logging-2.1.0/test/test_log_event.rb
vagrant-unbundled-1.8.5.1 vendor/bundle/ruby/2.3.0/gems/logging-2.1.0/test/test_log_event.rb
vagrant-unbundled-1.8.4.2 vendor/bundle/ruby/2.3.0/gems/logging-2.1.0/test/test_log_event.rb
vagrant-unbundled-1.8.4.1 vendor/bundle/ruby/2.3.0/gems/logging-2.1.0/test/test_log_event.rb
logging-2.1.0 test/test_log_event.rb
logging-2.0.0 test/test_log_event.rb