ia64/xen-unstable
changeset 13199:088752354770
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@xensource.com>
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@xensource.com>
author | Ewan Mellor <ewan@xensource.com> |
---|---|
date | Wed Dec 27 15:39:04 2006 +0000 (2006-12-27) |
parents | 11b9ccdc9417 |
children | 069d1364af53 |
files | tools/python/xen/xend/XendLogging.py |
line diff
1.1 --- a/tools/python/xen/xend/XendLogging.py Wed Dec 27 11:49:59 2006 +0000 1.2 +++ b/tools/python/xen/xend/XendLogging.py Wed Dec 27 15:39:04 2006 +0000 1.3 @@ -16,7 +16,10 @@ 1.4 # Copyright (C) 2005, 2006 XenSource Ltd. 1.5 #============================================================================ 1.6 1.7 +import inspect 1.8 import os 1.9 +import os.path 1.10 +import sys 1.11 import stat 1.12 import tempfile 1.13 import types 1.14 @@ -38,6 +41,24 @@ if 'TRACE' not in logging.__dict__: 1.15 self.log(logging.TRACE, *args, **kwargs) 1.16 logging.Logger.trace = trace 1.17 1.18 + def findCaller(self): 1.19 + """ 1.20 + Override logging.Logger.findCaller so that the above trace function 1.21 + does not appear as the source of log messages. The signature of this 1.22 + function changed between Python 2.3 and 2.4. 1.23 + """ 1.24 + frames = inspect.stack() 1.25 + thisfile = os.path.normcase(frames[0][1]) 1.26 + for frame in frames: 1.27 + filename = os.path.normcase(frame[1]) 1.28 + if filename != thisfile and filename != logging._srcfile: 1.29 + major, minor, _, _, _ = sys.version_info 1.30 + if major == 2 and minor >= 4: 1.31 + return filename, frame[2], frame[3] 1.32 + else: 1.33 + return filename, frame[2] 1.34 + logging.Logger.findCaller = findCaller 1.35 + 1.36 1.37 log = logging.getLogger("xend") 1.38 1.39 @@ -46,7 +67,7 @@ MAX_BYTES = 1 << 20 # 1MB 1.40 BACKUP_COUNT = 5 1.41 1.42 STDERR_FORMAT = "[%(name)s] %(levelname)s (%(module)s:%(lineno)d) %(message)s" 1.43 -LOGFILE_FORMAT = "[%(asctime)s %(name)s %(process)d] %(levelname)s (%(module)s:%(lineno)d) %(message)s" 1.44 +LOGFILE_FORMAT = "[%(asctime)s %(process)d] %(levelname)s (%(module)s:%(lineno)d) %(message)s" 1.45 DATE_FORMAT = "%Y-%m-%d %H:%M:%S" 1.46 1.47