in scripts/yapl/Trace.py [0:0]
def _log(self,methodName,eventType,msg,exc=None):
"""
Emit the trace message to stdout and optionally to a trace file when a trace file
has been defined.
All public Trace methods that emit trace messages go through _log() to actually
emit the trace in order to correctly unwind the call stack as well as to emit trace
in a thread safe manor.
"""
stackDump = None
threadId = ("%x" % thread.get_ident()).rjust(12).replace(" ","0")
traceString = "%s %s %s %s" % (self._getTimeStamp(),threadId,eventType,self.entityName)
traceString = "%s(%s) %s" % (traceString,self._sourceLineNumber(),methodName)
if (exc):
# Get stack dump now to keep it with msg text
if (Trace.StackTraceStyle == Trace.TopToBottom):
stackDump = self._exceptionStackTTB(methodName,exc)
elif (Trace.StackTraceStyle == Trace.BottomToTop):
stackDump = self._exceptionStackBTT(methodName,exc)
else:
raise TraceConfigurationException("'%s', is not a valid stack trace style. Expected one of %s" % (Trace.StackTraceStyle,Trace.StackTraceStyles))
#endIf
#endIf
# If a logFile was provided then send all trace to trace log
if (Trace.traceFile):
# file IO is not thread safe
# The Jython 2.1 that comes with WAS doesn't support the "with" statement.
try:
Trace.traceFileLock.acquire()
if (stackDump):
Trace.traceFile.write("%s : %s\n%s\n" % (traceString, msg, stackDump))
else:
Trace.traceFile.write("%s : %s\n" % (traceString, msg))
#endIf
Trace.traceFile.flush()
finally:
Trace.traceFileLock.release()
#endTry
#endIf
if (not Trace.traceFile or eventType in ["S", "E", "W", "I"]):
# Send severe, error, warning and info trace to stdout
if (stackDump):
print "%s : %s\n%s" % (traceString, msg, stackDump)
else:
print "%s : %s" % (traceString, msg)