Skip to content

Conversation

@bmodotdev
Copy link
Contributor

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.

@bmodotdev bmodotdev marked this pull request as ready for review September 13, 2021 02:55
@bmodotdev
Copy link
Contributor Author

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!

@bmodotdev bmodotdev force-pushed the screen-appender-stderr-per-log4p_level branch 2 times, most recently from 0615a7c to eb1f640 Compare September 16, 2021 23:34
@mohawk2 mohawk2 force-pushed the master branch 4 times, most recently from 01d6239 to 4c69f91 Compare June 1, 2022 22:21
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 go to STDERR. The legacy behavior of sending all to STDOUT or STDERR is still supported.
@mohawk2 mohawk2 force-pushed the screen-appender-stderr-per-log4p_level branch from eb1f640 to f15d389 Compare June 1, 2022 23:15
@coveralls
Copy link

Pull Request Test Coverage Report for Build 2425012954

  • 5 of 5 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.05%) to 89.78%

Totals Coverage Status
Change from base Build 2424937701: 0.05%
Covered Lines: 2372
Relevant Lines: 2642

💛 - Coveralls
@mohawk2 mohawk2 merged commit 799d729 into mschilli:master Jun 1, 2022
@mohawk2
Copy link
Collaborator

mohawk2 commented Jun 1, 2022

Thanks!

@bmodotdev
Copy link
Contributor Author

Thank you!

@coveralls
Copy link

coveralls commented Nov 13, 2024

Pull Request Test Coverage Report for Build 2425012954

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 5 of 5 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.05%) to 89.78%

Totals Coverage Status
Change from base Build 2424937701: 0.05%
Covered Lines: 2372
Relevant Lines: 2642

💛 - Coveralls
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants