Change in vdsm[master]: misc.py: fix logskip

danken at redhat.com danken at redhat.com
Sat Apr 27 19:39:08 UTC 2013


Dan Kenigsberg has submitted this change and it was merged.

Change subject: misc.py: fix logskip
......................................................................


misc.py: fix logskip

The intention of logskip is to change the caller information appeared in
log messages. It goes back and skip the stack frames that we do want to
ignore, then find the nearest caller frame that is not tagged as "should
skip", and use its filename, line number and function name information
as the caller information in the log message. It's useful to skip stack
frame of some utility function and log caller of the utility function.

The original logskip mechanism has two bugs. It overrides the standard
logger's findCaller method in function enableLogSkip(), however
enableLogSkip() itself will appear in the stack because the overriding
function refers a local variable "skipFunc" in the enableLogSkip(), thus
the Python interpreter has to keep the stack frame for a closure. We can
not avoid the closure so the soluion is adding function enableLogSkip()
itself to the "should skip" list.

This patch adds function enableLogSkip() itself to the "should skip"
list by prepending the "logskip" decorator to it.

Another bug is when deciding if we should skip the current frame, the
first condition branch in function _shouldLogSkip() does not properly
handle the following case. When the "logSkipName" is assigned and the
current frame's function body is not registered as skip,
_shouldLogSkip() thinks we should not skip. Howerver it's possible that
the whole source file is registered in this case, so we should skip this
frame as well. This patch fixes this problem.

Change-Id: Ib89dc6460ae33cb429ab1f170562f84dbc4010a8
Signed-off-by: Zhou Zheng Sheng <zhshzhou at linux.vnet.ibm.com>
---
M vdsm/storage/misc.py
1 file changed, 12 insertions(+), 11 deletions(-)

Approvals:
  Mark Wu: Looks good to me, but someone else must approve
  Dan Kenigsberg: Looks good to me, approved
  Zhou Zheng Sheng: Verified


--
To view, visit http://gerrit.ovirt.org/14264
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ib89dc6460ae33cb429ab1f170562f84dbc4010a8
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Zhou Zheng Sheng <zhshzhou at linux.vnet.ibm.com>
Gerrit-Reviewer: Dan Kenigsberg <danken at redhat.com>
Gerrit-Reviewer: Mark Wu <wudxw at linux.vnet.ibm.com>
Gerrit-Reviewer: Saggi Mizrahi <smizrahi at redhat.com>
Gerrit-Reviewer: Zhou Zheng Sheng <zhshzhou at linux.vnet.ibm.com>
Gerrit-Reviewer: oVirt Jenkins CI Server


More information about the vdsm-patches mailing list