ruby-changes:57966
From: George <ko1@a...>
Date: Fri, 27 Sep 2019 07:01:59 +0900 (JST)
Subject: [ruby-changes:57966] 31339ef4f2 (master): Honor Syslog::Logger#level overrides
https://git.ruby-lang.org/ruby.git/commit/?id=31339ef4f2 From 31339ef4f2af9c7dad2a81eaa9470ee4574181a0 Mon Sep 17 00:00:00 2001 From: George Claghorn <george@b...> Date: Wed, 11 Sep 2019 15:47:20 -0400 Subject: Honor Syslog::Logger#level overrides diff --git a/ext/syslog/lib/syslog/logger.rb b/ext/syslog/lib/syslog/logger.rb index 06cbe5b..453ca27 100644 --- a/ext/syslog/lib/syslog/logger.rb +++ b/ext/syslog/lib/syslog/logger.rb @@ -112,7 +112,7 @@ class Syslog::Logger https://github.com/ruby/ruby/blob/trunk/ext/syslog/lib/syslog/logger.rb#L112 end def #{meth}? - @level <= #{level} + level <= #{level} end EOM end @@ -202,7 +202,7 @@ class Syslog::Logger https://github.com/ruby/ruby/blob/trunk/ext/syslog/lib/syslog/logger.rb#L202 def add severity, message = nil, progname = nil, &block severity ||= ::Logger::UNKNOWN - @level <= severity and + level <= severity and @@syslog.log( (LEVEL_MAP[severity] | @facility), '%s', formatter.call(severity, Time.now, progname, (message || block.call)) ) true end diff --git a/test/syslog/test_syslog_logger.rb b/test/syslog/test_syslog_logger.rb index 5e0cc76..d9ffae3 100644 --- a/test/syslog/test_syslog_logger.rb +++ b/test/syslog/test_syslog_logger.rb @@ -551,6 +551,21 @@ class TestSyslogLogger < TestSyslogRootLogger https://github.com/ruby/ruby/blob/trunk/test/syslog/test_syslog_logger.rb#L551 assert_equal facility|Syslog::LOG_DEBUG, msg.priority end + class CustomSyslogLogger < Syslog::Logger + def level + Logger::INFO + end + end + + def test_overriding_level + @logger = CustomSyslogLogger.new + log = log_add Logger::INFO, 'msg' + assert_equal 'msg', log.msg + + log = log_add Logger::DEBUG, 'msg' + assert_nil log.msg + end + end if defined?(Syslog) -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/