Skip to content

Conversation

fgeueke
Copy link
Contributor

@fgeueke fgeueke commented Jul 21, 2014

In using the Boolean filter I noticed that it wasn't shortcutting in evaluating the logic parameter. It is hoped that with this update the boolean logic will be evaluated once instead of in pieces (where all pieces get evaluated).

A simple test conf:

log4perl.category.test = DEBUG, Screen

log4perl.filter.Debug = Log::Log4perl::Filter::LevelMatch
log4perl.filter.Debug.LevelToMatch = DEBUG
log4perl.filter.Debug.AcceptOnMatch = true

log4perl.filter.Info = Log::Log4perl::Filter::LevelMatch
log4perl.filter.Info.LevelToMatch = INFO
log4perl.filter.Info.AcceptOnMatch = true

log4perl.filter.Boolean = Log::Log4perl::Filter::Boolean
log4perl.filter.Boolean.logic = Debug && Info

log4perl.appender.Screen = Log::Log4perl::Appender::Screen
log4perl.appender.Screen.layout = Log::Log4perl::Layout::SimpleLayout
log4perl.appender.Screen.Filter = Boolean

With this revision $logger->info() will hit LevelMatch::ok() once where previously it would've hit it twice (even though the logic should prevent the second call from happening.

@mschilli
Copy link
Owner

Thanks for your contribution! I'll add the tests I verified your patch with shortly.

mschilli added a commit that referenced this pull request Jul 23, 2014
Updated Boolean.pm to evaluate filter in a single eval.
@mschilli mschilli merged commit 7059221 into mschilli:master Jul 23, 2014
mschilli added a commit that referenced this pull request Jul 23, 2014
mschilli added a commit that referenced this pull request Jul 23, 2014
jsonn pushed a commit to jsonn/pkgsrc that referenced this pull request Jan 19, 2015
Upstream changes:
1.46 (2014/10/31)
   *    (ms) Fixed Gianni's utc time test for machines set to utc time.

1.45 (2014/10/25)
   *    (ms) fgeueke provided a pull request for short-circuiting boolean
             filters: mschilli/log4perl#48
   *    (ms) [rt.cpan.org #94009] Tim Bunce had requested that the
             PatternLayout's %m specifier allow for fixed indentation,
             variable indentation, and at the same time permit the use
             of the chomp option. Added with tests and docs.
   *    (ms) Gianni Ceccarelli added the log4perl.utcDateTimes config
             option to select UTC instead of localtime:
             mschilli/log4perl#53
   *    (ms) @bokutin fixed Catalyst.pm buffer flush:
               mschilli/log4perl#51
               mschilli/log4perl#54

1.44 (2014/05/17)
   *    (ms) Skipped mkpath umask tests on Win32 which doesn't support it
             properly.
   *    (ms) Requiring core module File::Path 2.06_06, which has remove_tree()
             (fixes test suite for ancient perl-5.6.2).
   *    (ms) Brian Wightman fixed temporary file cleanup in the test suite
             for Win32: mschilli/log4perl#45

1.43 (2014/03/16)
   *    (ms) Added %m{indent} to indent multi-line messages according to the
             PatternLayout (inspired by Wolfgang Pecho)
   *    (ms) [rt.cpan.org #84818] Deven T. Corzine suggested adding
             a conditional use Win32 on Win32 platform to fix a
             chicken-and-egg problem with the resurrector.
   *    (ms) Brian Wightman fixed Win32 log file cleanup in test suite
             mschilli/log4perl#39. New FAQ
             entry on Win32 log file cleanup.

1.42 (2013/07/25)
   *    (ms) BenRifkah Bergsten-Buret added ';!' for property configurator
             comment delimiters:
             mschilli/log4perl#25
   *    (ms) [rt.cpan.org 84723] Suppress error if close() in the file
             appender in pipe mode returns "No child processes".
   *    (ms) Ronald J Kimball fixed a bug with the file appender's
             create_at_logtime option in combination with
             recreate_check_signal:
             mschilli/log4perl#28
   *    (ms) Fixed additivity() modifications after init():
             mschilli/log4perl#29
   *    (ms) [rt.cpan.org 87191] Applied patch by Zefram for better
             maintainable line number checks (and coping with 5.19 buggy
             line numbering, cough, cough).

1.41 (2013/04/21)
   *    (ms) [rt 81731] Added 'trace' level to Log4perl::Catalyst, as
             suggested by Ashley Pond.
   *    (ms) Alexander Hartmaier added Log::Log4perl::Filter::MDC to filter
             based on MDC key/value
   *    (ms) [rt.cpan.org 83193] The file appender now ignores owner/group
             settings on all types of existing file system entries (previously,
             this was only the case for actual files).
   *    (ms) [rt.cpan.org 84289] Documented Level.pm's isGreaterOrEqual()
             comparator.
   *    (ms) [rt.cpan.org #84725] Fixed test suite to allow running tests
             in parallel via HARNESS_OPTIONS=j10:c HARNESS_TIMER=1.
             Reported by Brendan Byrd.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants