WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] Override logging.Logger.findCaller so tha

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] Override logging.Logger.findCaller so that the trace function here does not
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Fri, 29 Dec 2006 14:20:07 -0800
Delivery-date: Fri, 29 Dec 2006 14:20:34 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Ewan Mellor <ewan@xxxxxxxxxxxxx>
# Date 1167233944 0
# Node ID 088752354770f76b9dc96575289a8dac4e73ca09
# Parent  11b9ccdc94175a468667fa9313dc6ddf3fe652b0
Override logging.Logger.findCaller so that the trace function here does not
appear as the source of log messages.

Remove the logger name from the log format -- it's adding no useful information.

Signed-off-by: Ewan Mellor <ewan@xxxxxxxxxxxxx>
---
 tools/python/xen/xend/XendLogging.py |   23 ++++++++++++++++++++++-
 1 files changed, 22 insertions(+), 1 deletion(-)

diff -r 11b9ccdc9417 -r 088752354770 tools/python/xen/xend/XendLogging.py
--- a/tools/python/xen/xend/XendLogging.py      Wed Dec 27 11:49:59 2006 +0000
+++ b/tools/python/xen/xend/XendLogging.py      Wed Dec 27 15:39:04 2006 +0000
@@ -16,7 +16,10 @@
 # Copyright (C) 2005, 2006 XenSource Ltd.
 #============================================================================
 
+import inspect
 import os
+import os.path
+import sys
 import stat
 import tempfile
 import types
@@ -38,6 +41,24 @@ if 'TRACE' not in logging.__dict__:
         self.log(logging.TRACE, *args, **kwargs)
     logging.Logger.trace = trace
 
+    def findCaller(self):
+        """
+        Override logging.Logger.findCaller so that the above trace function
+        does not appear as the source of log messages.  The signature of this
+        function changed between Python 2.3 and 2.4.
+        """
+        frames = inspect.stack()
+        thisfile = os.path.normcase(frames[0][1])
+        for frame in frames:
+            filename = os.path.normcase(frame[1])
+            if filename != thisfile and filename != logging._srcfile:
+                major, minor, _, _, _ = sys.version_info
+                if major == 2 and minor >= 4:
+                    return filename, frame[2], frame[3]
+                else:
+                    return filename, frame[2]
+    logging.Logger.findCaller = findCaller
+
 
 log = logging.getLogger("xend")
 
@@ -46,7 +67,7 @@ BACKUP_COUNT = 5
 BACKUP_COUNT = 5
 
 STDERR_FORMAT = "[%(name)s] %(levelname)s (%(module)s:%(lineno)d) %(message)s"
-LOGFILE_FORMAT = "[%(asctime)s %(name)s %(process)d] %(levelname)s 
(%(module)s:%(lineno)d) %(message)s"
+LOGFILE_FORMAT = "[%(asctime)s %(process)d] %(levelname)s 
(%(module)s:%(lineno)d) %(message)s"
 DATE_FORMAT = "%Y-%m-%d %H:%M:%S"
 
 

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] Override logging.Logger.findCaller so that the trace function here does not, Xen patchbot-unstable <=