Sha256: 5c0ed92f814e066e064e6cd0aac4fe6c242087d90819920ea247563a43a224d5
Contents?: true
Size: 1.2 KB
Versions: 15
Compression:
Stored size: 1.2 KB
Contents
# -*- encoding: utf-8 -*- require 'minitest/autorun' require 'stringio' require 'webgen/logger' class TestLogger < Minitest::Test def test_logging @logio = StringIO.new logger = Webgen::Logger.new(@logio) logger.formatter = Proc.new do |severity, timestamp, progname, msg| "#{severity} #{msg}\n" end logger.verbose = false logger.debug { ["debug", "verbose"]} assert_log(/^DEBUG debug$/) logger.info {["info", "verbose"]} assert_log(/^INFO info$/) logger.warn {["warn", "verbose"]} assert_log(/^WARN warn$/) logger.error {["error", "verbose"]} assert_log(/^ERROR error$/) logger.vinfo {["verbose", "verbose"]} assert_log(/^$/) logger.verbose = true logger.debug { ["debug", "verbose"]} assert_log(/^DEBUG debug\nverbose$/) logger.info {["info", "verbose"]} assert_log(/^INFO info\nverbose$/) logger.warn {["warn", "verbose"]} assert_log(/^WARN warn\nverbose$/) logger.error {["error", "verbose"]} assert_log(/^ERROR error\nverbose$/) logger.vinfo {["verbose", "verbose"]} assert_log(/^INFO verbose\nverbose$/) end def assert_log(reg) assert_match(reg, @logio.string) @logio.string = '' end end
Version data entries
15 entries across 15 versions & 1 rubygems