Sha256: adb9ae59900d360fa943c22fd4f908abd8e3a6b58f64fd9e5eb820cb8cfdd4f0

Contents?: true

Size: 1.07 KB

Versions: 4

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 2, Logging::Logger.root.level # warn

    Bixby::Log.setup_logger(:level => :info)
    assert_equal 1, Logging::Logger.root.level # info
  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

4 entries across 4 versions & 1 rubygems

Version Path
bixby-common-0.4.12 test/util/log_test.rb
bixby-common-0.4.11 test/util/log_test.rb
bixby-common-0.4.10 test/util/log_test.rb
bixby-common-0.4.9 test/util/log_test.rb