Sha256: a5d582bbddc468003af6bfeff608b0c032448fd0dc7b14e3b583492c59157d0d

Contents?: true

Size: 1.2 KB

Versions: 61

Compression:

Stored size: 1.2 KB

Contents

require 'test_helper'

class TestMDC < TestCase
  include Log4r

  def test_multithread_copy
    Log4r::MDC.put("user","colbygk")
    t = Thread.new("test first copy") do |name|
      assert(Log4r::MDC.get("user") == "colbygk",
	     "Did not get back expected value, '#{MDC.get("user")}'")
      Log4r::MDC.put("user","unique")
      assert(Log4r::MDC.get("user") == "unique",
	     "Did not get back expected value, '#{MDC.get("user")}'")
    end
    t.join
    assert(Log4r::MDC.get("user") == "colbygk",
	   "Did not get back expected value, '#{MDC.get("user")}'")
  end

  def test_MDCoutput
    Log4r::MDC.put(:user, "symbol")
    Log4r::MDC.put("string", "string")
    Log4r::MDC.put(5, "number")
    l = Logger.new 'test'
    o = StdoutOutputter.new 'test'
    l.add o
    assert_nothing_raised {
      f = PatternFormatter.new :pattern=> "%l user: %X{:user} %X{strng} %X{5}"
      Outputter['test'].formatter = f
      l.debug "And this?"
      l.info "How's this?"
      l.error "and a really freaking huge line which we hope will be trimmed?"
      e = ArgumentError.new("something barfed")
      e.set_backtrace Array.new(5, "trace junk at thisfile.rb 154")
      l.fatal e
      l.info [1, 3, 5]
    }

  end
end

Version data entries

61 entries across 53 versions & 12 rubygems

Version Path
vagrant-unbundled-2.2.19.0 vendor/bundle/ruby/3.0.0/gems/log4r-1.1.10/tests/testMDC.rb
vagrant-unbundled-2.2.18.0 vendor/bundle/ruby/3.0.0/gems/log4r-1.1.10/tests/testMDC.rb
vagrant-unbundled-2.2.16.0 vendor/bundle/ruby/3.0.0/gems/log4r-1.1.10/tests/testMDC.rb
vagrant-unbundled-2.2.16.0 vendor/bundle/ruby/2.7.0/gems/log4r-1.1.10/tests/testMDC.rb
vagrant-unbundled-2.2.14.0 vendor/bundle/ruby/2.7.0/gems/log4r-1.1.10/tests/testMDC.rb
vagrant-unbundled-2.2.10.0 vendor/bundle/ruby/2.7.0/gems/log4r-1.1.10/tests/testMDC.rb
vagrant-unbundled-2.2.9.0 vendor/bundle/ruby/2.7.0/gems/log4r-1.1.10/tests/testMDC.rb
vagrant-unbundled-2.2.8.0 vendor/bundle/ruby/2.7.0/gems/log4r-1.1.10/tests/testMDC.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.4.0/gems/log4r-1.1.10/tests/testMDC.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.6.0/gems/log4r-1.1.10/tests/testMDC.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.7.0/gems/log4r-1.1.10/tests/testMDC.rb
vagrant-unbundled-2.2.6.2 vendor/bundle/ruby/2.6.0/gems/log4r-1.1.10/tests/testMDC.rb
vagrant-unbundled-2.2.6.1 vendor/bundle/ruby/2.6.0/gems/log4r-1.1.10/tests/testMDC.rb
vagrant-unbundled-2.2.6.0 vendor/bundle/ruby/2.6.0/gems/log4r-1.1.10/tests/testMDC.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.5.0/gems/log4r-1.1.10/tests/testMDC.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.6.0/gems/log4r-1.1.10/tests/testMDC.rb
vagrant-unbundled-2.2.4.0 vendor/bundle/ruby/2.5.0/gems/log4r-1.1.10/tests/testMDC.rb
vagrant-unbundled-2.2.4.0 vendor/bundle/ruby/2.6.0/gems/log4r-1.1.10/tests/testMDC.rb
vagrant-unbundled-2.2.3.0 vendor/bundle/ruby/2.5.0/gems/log4r-1.1.10/tests/testMDC.rb
vagrant-unbundled-2.2.2.0 vendor/bundle/ruby/2.5.0/gems/log4r-1.1.10/tests/testMDC.rb