Sha256: b3ce614be6d8d224f0c54f0aa97a49ffadf554da89136a45a8af6cf184e6dc8f

Contents?: true

Size: 1.07 KB

Versions: 10

Compression:

Stored size: 1.07 KB

Contents

require 'helper'

module Bixby
module Test

class TestLog < TestCase

  def test_setup_logger
    ENV["BIXBY_LOG"] = "DEBUG"
    Bixby::Log.setup_logger
    assert_equal 0, Logging::Logger.root.level # debug

    ENV["BIXBY_LOG"] = "error"
    Bixby::Log.setup_logger
    assert_equal 3, Logging::Logger.root.level # debug

    ENV.delete("BIXBY_LOG")
    Bixby::Log.setup_logger
    assert_equal 1, Logging::Logger.root.level # info

    Bixby::Log.setup_logger(:level => :error)
    assert_equal 3, Logging::Logger.root.level # error
  end

  def test_filtering_layout

    filter = Bixby::Log::FilteringLayout.new

    f = "foo"
    assert_equal "foo", filter.format_obj(f)
    assert filter.format_obj(nil) =~ /NilClass/
    assert filter.format_obj(3) =~ /Fixnum.*3/

    begin
      raise "foo"
    rescue => ex
      assert filter.format_obj(ex) =~ /micron/

      # filter out all turn lines
      filter.set_filter do |ex|
        ex.backtrace.reject{ |s| s =~ /micron/ }
      end
      refute filter.format_obj(ex) =~ /micron/

    end
  end

end # TestLog

end # Test
end # Bixby

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
bixby-common-0.7.0 test/util/log_test.rb
bixby-common-0.6.6 test/util/log_test.rb
bixby-common-0.6.5 test/util/log_test.rb
bixby-common-0.6.4 test/util/log_test.rb
bixby-common-0.6.3 test/util/log_test.rb
bixby-common-0.6.2 test/util/log_test.rb
bixby-common-0.6.1 test/util/log_test.rb
bixby-common-0.6.0 test/util/log_test.rb
bixby-common-0.5.0 test/util/log_test.rb
bixby-common-0.4.13 test/util/log_test.rb