Closed bmodotdev closed 2 years ago
I wrote this feature because I expect $ERROR and greater to go to STDERR and $WARN and lesser go to STDOUT. To me, this is nice for CI/CD so we can have a meaningful capture of STDERR.
So now, the supported configs lines are
# Legacy - all levels to STDOUT
log4perl.appender.Screen.stderr = 0
# Legacy - all levels to STDERR
log4perl.appender.Screen.stderr = 1
# New - only ERROR and FATAL to STDERR, the rest to STDOUT
log4perl.appender.Screen.stderr.ERROR = 1
log4perl.appender.Screen.stderr.FATAL = 1
I also added some testing for both legacy and new behavior here
$ prove -v -I './lib/' t/071ScreenStdoutStderr.t
t/071ScreenStdoutStderr.t ..
1..30
ok 1 - debug to stdout
ok 2 - debug to stderr
ok 3 - error to stdout
ok 4 - error to stderr
ok 5 - fatal to stdout
ok 6 - fatal to stderr
ok 7 - info to stdout
ok 8 - info to stderr
ok 9 - warn to stdout
ok 10 - warn to stderr
ok 11 - debug to stdout
ok 12 - debug to stderr
ok 13 - error to stdout
ok 14 - error to stderr
ok 15 - fatal to stdout
ok 16 - fatal to stderr
ok 17 - info to stdout
ok 18 - info to stderr
ok 19 - warn to stdout
ok 20 - warn to stderr
ok 21 - debug to stdout
ok 22 - debug to stderr
ok 23 - error to stdout
ok 24 - error to stderr
ok 25 - fatal to stdout
ok 26 - fatal to stderr
ok 27 - info to stdout
ok 28 - info to stderr
ok 29 - warn to stdout
ok 30 - warn to stderr
ok
All tests successful.
Files=1, Tests=30, 0 wallclock secs ( 0.02 usr 0.01 sys + 0.08 cusr 0.02 csys = 0.13 CPU)
Result: PASS
Let me know if there is already a better way to achieve mixed output or STDERR by level greater than $foo.
Thanks!
Totals | |
---|---|
Change from base Build 2424937701: | 0.05% |
Covered Lines: | 2372 |
Relevant Lines: | 2642 |
Thanks!
Thank you!
Currently “Log::Log4perl::Appender::Screen” and “ScreenColoredLevels” only support sending all levels to STDOUT or STDERR. This adds the ability to specify only certain log4p_level’s got to STDERR. The legacy behavior of sending all to STDOUT or STDERR is still supported.