[Bug 43166] New: Add optional Carp::Always styling behavior to Koha
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43166 Bug ID: 43166 Summary: Add optional Carp::Always styling behavior to Koha Initiative type: --- Sponsorship --- status: Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: Architecture, internals, and plumbing Assignee: koha-bugs@lists.koha-community.org Reporter: kyle@bywatersolutions.com QA Contact: testopia@bugs.koha-community.org Target Milestone: --- -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43166 Kyle M Hall (khall) <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|koha-bugs@lists.koha-commun |kyle@bywatersolutions.com |ity.org | -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43166 Kyle M Hall (khall) <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |kyle@bywatersolutions.com, | |nick@bywatersolutions.com, | |tristin.stagg@bywatersoluti | |ons.com -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43166 Kyle M Hall (khall) <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43166 --- Comment #1 from Kyle M Hall (khall) <kyle@bywatersolutions.com> --- Created attachment 202820 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=202820&action=edit Bug 43166: Add Koha::CarpAlways to append stack traces to warnings and errors Some warnings and errors are very difficult to track down because the message gives only the immediate file and line number, not the call path that led there. The CPAN module Carp::Always solves this, but it can only be enabled process-wide, which floods the logs when all you care about is one script, and it is not a Koha dependency. This patch adds Koha::CarpAlways, which appends a full stack trace to warnings and errors using core Carp, scoped to the scripts listed in the new carp_always entry in koha-conf.xml or in the KOHA_CARP_ALWAYS environment variable. The value is a space or comma separated list of script names, or 1 or * for all scripts. This patch adds the module only. It is wired into Plack, Koha::Script and the SIP server by the follow-up patches. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43166 --- Comment #2 from Kyle M Hall (khall) <kyle@bywatersolutions.com> --- Created attachment 202821 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=202821&action=edit Bug 43166: Add unit tests for Koha::CarpAlways Test Plan: 1) Apply this patch 2) prove t/Koha/CarpAlways.t -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43166 --- Comment #3 from Kyle M Hall (khall) <kyle@bywatersolutions.com> --- Created attachment 202822 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=202822&action=edit Bug 43166: Add Koha::Middleware::CarpAlways This patch adds a Plack middleware that localizes the warn and die handlers around a request when the request path matches the carp_always configuration. This makes the stack traces per script even though Plack workers are shared between all scripts. The middleware must be enabled after Plack::Middleware::LogWarn, which installs its own warn handler without chaining. Enabled after it, our handler runs first and chains to LogWarn's, so the traces land in the same plack error logs the plain warnings would have. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43166 --- Comment #4 from Kyle M Hall (khall) <kyle@bywatersolutions.com> --- Created attachment 202823 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=202823&action=edit Bug 43166: Add unit tests for Koha::Middleware::CarpAlways Test Plan: 1) Apply this patch 2) prove t/Koha/Middleware/CarpAlways.t -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43166 --- Comment #5 from Kyle M Hall (khall) <kyle@bywatersolutions.com> --- Created attachment 202824 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=202824&action=edit Bug 43166: Enable stack traces for Plack and add carp_always to koha-conf.xml This patch enables Koha::Middleware::CarpAlways for the OPAC, staff interface, svc and REST API mounts, and documents the new carp_always entry in the koha-conf.xml templates. Test Plan: 1) Apply this patch 2) Add <carp_always>1</carp_always> to your instance's koha-conf.xml 3) Add a temporary warn to mainpage.pl, e.g. warn "Testing"; 4) Restart all the things! 5) Load the staff interface main page 6) Note the warning in plack-intranet-error.log now has a full stack trace! 7) Add a temporary warn to an API controller and hit that route, note the trace in plack-api-error.log! 8) Change the entry to <carp_always>moremember.pl</carp_always> and restart plack 9) Load the staff interface main page again 10) Note the warning is back to a single line, traces only apply to the scripts listed! 11) Remove the temporary warns -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43166 --- Comment #6 from Kyle M Hall (khall) <kyle@bywatersolutions.com> --- Created attachment 202825 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=202825&action=edit Bug 43166: Enable stack traces for command line scripts via Koha::Script Any script that uses Koha::Script now installs the handlers at compile time when its name matches the carp_always configuration. Scripts that don't use Koha::Script can be run as 'perl -MCarp::Always script.pl' instead. Test Plan: 1) Apply this patch 2) In a koha shell, run: KOHA_CARP_ALWAYS='*' perl -MKoha::Script -e 'sub f { warn "hi" } f()' 3) Note the warning has a stack trace! 4) Run the same with KOHA_CARP_ALWAYS=0, note the trace is gone! 5) prove t/Koha/Script.t -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43166 --- Comment #7 from Kyle M Hall (khall) <kyle@bywatersolutions.com> --- Created attachment 202826 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=202826&action=edit Bug 43166: Append stack traces to SIP server warnings and errors The SIP server ties STDERR to C4::SIP::Trapper and installs its own global die handler, so the Plack middleware approach doesn't apply there. Instead, Trapper appends the trace itself when SIPServer.pm matches the carp_always configuration. Test Plan: 1) Apply this patch 2) Add <carp_always>SIPServer.pm</carp_always> to your instance's koha-conf.xml 3) Add a temporary warn to process_request in C4/SIP/SIPServer.pm 4) Restart the SIP server 5) Connect to the SIP port, e.g. echo | nc localhost 6001 6) Note the warning in sip-output.log now has a full stack trace! 7) Remove the temporary warn -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org