Allow first argument to logger to be string or subroutine

Bug #1824181 reported by John Merriam
12
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenSRF
Fix Released
Medium
Unassigned
3.0
Fix Released
Medium
Unassigned

Bug Description

This simple change allows the $msg passed to _log_message in Logger.pm to be either a regular string or a delayed exec subroutine. This is in reaction to LP1823338 where a slow debug logging statement was slowing down SIP checkins even though debug logging was not turned on.

With this change you can take this:

$log->debug("Available methods\n\t".join("\n\t", keys %{ $_METHODS[$proto] }), INTERNAL);

and change it to this:

$log->debug(sub{return "Available methods\n\t".join("\n\t", keys %{ $_METHODS[$proto] }) }, INTERNAL);

and then that slow debug logging line will not be executed unless debug logging is turned on.

Branch to follow.

Revision history for this message
John Merriam (jmerriam) wrote :
tags: added: pullrequest
Revision history for this message
John Merriam (jmerriam) wrote :

LP1824184 https://bugs.launchpad.net/opensrf/+bug/1824184
is the followup to this where we actually start making use of it.

Galen Charlton (gmc)
Changed in opensrf:
status: New → Confirmed
importance: Undecided → Medium
Revision history for this message
Galen Charlton (gmc) wrote :

Pushed to master, rel_3_1, and rel_3_0. Thanks, John!

tags: added: performance
Changed in opensrf:
milestone: none → 3.1.1
status: Confirmed → Fix Committed
Galen Charlton (gmc)
Changed in opensrf:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.