version 1.23, 2004/06/22 22:06:23
|
version 1.34, 2006/01/30 16:17:08
|
|
|
//%2003//////////////////////////////////////////////////////////////////////// |
//%2006//////////////////////////////////////////////////////////////////////// |
// | // |
// Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Development |
// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development |
// Company, L. P., IBM Corp., The Open Group, Tivoli Systems. |
// Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems. |
// Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L. P.; | // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L. P.; |
// IBM Corp.; EMC Corporation, The Open Group. | // IBM Corp.; EMC Corporation, The Open Group. |
|
// Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.; |
|
// IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group. |
|
// Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.; |
|
// EMC Corporation; VERITAS Software Corporation; The Open Group. |
|
// Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.; |
|
// EMC Corporation; Symantec Corporation; The Open Group. |
// | // |
// Permission is hereby granted, free of charge, to any person obtaining a copy | // Permission is hereby granted, free of charge, to any person obtaining a copy |
// of this software and associated documentation files (the "Software"), to | // of this software and associated documentation files (the "Software"), to |
|
|
// Modified By: Jenny Yu, Hewlett-Packard Company (jenny_yu@hp.com) | // Modified By: Jenny Yu, Hewlett-Packard Company (jenny_yu@hp.com) |
// Amit K Arora, IBM (amita@in.ibm.com) for PEP#101 | // Amit K Arora, IBM (amita@in.ibm.com) for PEP#101 |
// Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com) | // Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com) |
|
// Josephine Eskaline Joyce, IBM (jojustin@in.ibm.com) for Bug#2498 |
|
// Sean Keenan, Hewlett-Packard Company (sean.keenan@hp.com) |
|
// David Dillard, Symantec Corp. (david_dillard@symantec.com) |
|
// Aruran, IBM (ashanmug@in.ibm.com) for Bug# 4547 |
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
|
|
// Set the max PID and Thread ID Length | // Set the max PID and Thread ID Length |
const Uint32 Tracer::_STRLEN_MAX_PID_TID = 20; | const Uint32 Tracer::_STRLEN_MAX_PID_TID = 20; |
| |
|
// Initialize public indicator of trace state |
|
Boolean Tracer::_traceOn = false; |
|
|
//////////////////////////////////////////////////////////////////////////////// | //////////////////////////////////////////////////////////////////////////////// |
// Tracer constructor | // Tracer constructor |
// Constructor is private to preclude construction of Tracer objects | // Constructor is private to preclude construction of Tracer objects |
// Single Instance of Tracer is maintained for each process. | // Single Instance of Tracer is maintained for each process. |
//////////////////////////////////////////////////////////////////////////////// | //////////////////////////////////////////////////////////////////////////////// |
Tracer::Tracer() | Tracer::Tracer() |
|
: _traceComponentMask(new Boolean[_NUM_COMPONENTS]), |
|
_traceLevelMask(0), |
|
_traceHandler(new TraceFileHandler()) |
{ | { |
// Initialize Trace File Handler |
|
_traceHandler.reset(new TraceFileHandler()); |
|
_traceLevelMask=0; |
|
_traceComponentMask.reset(new Boolean[_NUM_COMPONENTS]); |
|
|
|
// Initialize ComponentMask array to false | // Initialize ComponentMask array to false |
for (Uint32 index=0;index < _NUM_COMPONENTS; | for (Uint32 index=0;index < _NUM_COMPONENTS; |
(_traceComponentMask.get())[index++]=false); | (_traceComponentMask.get())[index++]=false); |
|
|
_STRLEN_MAX_UNSIGNED_INT + (_STRLEN_MAX_PID_TID * 2) + 8 ]; | _STRLEN_MAX_UNSIGNED_INT + (_STRLEN_MAX_PID_TID * 2) + 8 ]; |
sprintf( | sprintf( |
message, | message, |
|
#if defined(PEGASUS_OS_VMS) |
|
// |
|
// pegasus_thread_self returns long-long-unsigned. |
|
// |
|
"[%d:%llu:%s:%u]: ", |
|
// "[%x:%llx:%s:%u]: ", |
|
System::getPID(), |
|
pegasus_thread_self(), |
|
#else |
"[%d:%u:%s:%u]: ", | "[%d:%u:%s:%u]: ", |
System::getPID(), | System::getPID(), |
Uint32(pegasus_thread_self()), | Uint32(pegasus_thread_self()), |
|
#endif |
fileName, | fileName, |
lineNum); | lineNum); |
| |
|
|
message = new char[ strlen(fileName) + | message = new char[ strlen(fileName) + |
_STRLEN_MAX_UNSIGNED_INT + (_STRLEN_MAX_PID_TID * 2) + 8 ]; | _STRLEN_MAX_UNSIGNED_INT + (_STRLEN_MAX_PID_TID * 2) + 8 ]; |
| |
|
#if defined(PEGASUS_OS_VMS) |
|
// |
|
// pegasus_thread_self returns long-long-unsigned. |
|
// |
|
sprintf( |
|
message, |
|
"[%d:%llu:%s:%u]: ", |
|
System::getPID(), |
|
pegasus_thread_self(), |
|
fileName, |
|
lineNum); |
|
#else |
sprintf( | sprintf( |
message, | message, |
"[%d:%u:%s:%u]: ", | "[%d:%u:%s:%u]: ", |
|
|
Uint32(pegasus_thread_self()), | Uint32(pegasus_thread_self()), |
fileName, | fileName, |
lineNum); | lineNum); |
|
#endif |
_trace(traceComponent,message,fmt,argList); | _trace(traceComponent,message,fmt,argList); |
| |
va_end(argList); | va_end(argList); |
|
|
message = new char[ strlen(fileName) + | message = new char[ strlen(fileName) + |
_STRLEN_MAX_UNSIGNED_INT + (_STRLEN_MAX_PID_TID * 2) + 8 ]; | _STRLEN_MAX_UNSIGNED_INT + (_STRLEN_MAX_PID_TID * 2) + 8 ]; |
| |
|
#if defined(PEGASUS_OS_VMS) |
|
// |
|
// pegasus_thread_self returns long-long-unsigned. |
|
// |
|
sprintf( |
|
message, |
|
"[%d:%llu:%s:%u]: ", |
|
System::getPID(), |
|
pegasus_thread_self(), |
|
fileName, |
|
lineNum); |
|
#else |
sprintf( | sprintf( |
message, | message, |
"[%d:%u:%s:%u]: ", | "[%d:%u:%s:%u]: ", |
|
|
Uint32(pegasus_thread_self()), | Uint32(pegasus_thread_self()), |
fileName, | fileName, |
lineNum); | lineNum); |
|
#endif |
_trace(traceComponent,message,fmt,argList); | _trace(traceComponent,message,fmt,argList); |
va_end(argList); | va_end(argList); |
| |
|
|
// Construct the message header | // Construct the message header |
// The message header is in the following format | // The message header is in the following format |
// timestamp: <component name> [file name:line number] | // timestamp: <component name> [file name:line number] |
if (strcmp(message,"") != 0) |
if (*message != '\0') |
{ | { |
// << Wed Jul 16 10:58:40 2003 mdd >> _STRLEN_MAX_PID_TID is not used in this format string | // << Wed Jul 16 10:58:40 2003 mdd >> _STRLEN_MAX_PID_TID is not used in this format string |
msgHeader = new char [strlen(message) | msgHeader = new char [strlen(message) |
|
|
// Needs to be updated if additional info is added | // Needs to be updated if additional info is added |
// | // |
tmpBuffer = new char[_STRLEN_MAX_PID_TID + 6]; | tmpBuffer = new char[_STRLEN_MAX_PID_TID + 6]; |
|
#if defined(PEGASUS_OS_VMS) |
|
// |
|
// pegasus_thread_self returns long-long-unsigned. |
|
// |
|
sprintf(tmpBuffer, "[%u:%llu]: ", System::getPID(), |
|
pegasus_thread_self()); |
|
#else |
sprintf(tmpBuffer, "[%u:%u]: ", System::getPID(), | sprintf(tmpBuffer, "[%u:%u]: ", System::getPID(), |
Uint32(pegasus_thread_self())); | Uint32(pegasus_thread_self())); |
|
#endif |
msgHeader = new char [ strlen(timeStamp) + strlen(TRACE_COMPONENT_LIST[traceComponent]) + | msgHeader = new char [ strlen(timeStamp) + strlen(TRACE_COMPONENT_LIST[traceComponent]) + |
strlen(tmpBuffer) + 1 + 5 ]; | strlen(tmpBuffer) + 1 + 5 ]; |
| |
|
|
//////////////////////////////////////////////////////////////////////////////// | //////////////////////////////////////////////////////////////////////////////// |
Uint32 Tracer::setTraceFile(const char* traceFile) | Uint32 Tracer::setTraceFile(const char* traceFile) |
{ | { |
|
if (*traceFile == 0) |
|
{ |
|
return 1; |
|
} |
|
|
String moduleName = _getInstance()->_moduleName; | String moduleName = _getInstance()->_moduleName; |
if (moduleName == String::EMPTY) | if (moduleName == String::EMPTY) |
{ | { |
|
|
{ | { |
for (index=0; index < _NUM_COMPONENTS; | for (index=0; index < _NUM_COMPONENTS; |
(_getInstance()->_traceComponentMask.get())[index++] = true); | (_getInstance()->_traceComponentMask.get())[index++] = true); |
|
_traceOn = true; |
return ; | return ; |
} | } |
| |
// initialise ComponentMask array to False | // initialise ComponentMask array to False |
for (index = 0;index < _NUM_COMPONENTS; | for (index = 0;index < _NUM_COMPONENTS; |
(_getInstance()->_traceComponentMask.get())[index++] = false); | (_getInstance()->_traceComponentMask.get())[index++] = false); |
|
_traceOn = false; |
| |
// Append _COMPONENT_SEPARATOR to the end of the traceComponents | // Append _COMPONENT_SEPARATOR to the end of the traceComponents |
componentStr.append(_COMPONENT_SEPARATOR); | componentStr.append(_COMPONENT_SEPARATOR); |
|
|
componentName,TRACE_COMPONENT_LIST[index])) | componentName,TRACE_COMPONENT_LIST[index])) |
{ | { |
(_getInstance()->_traceComponentMask.get())[index]=true; | (_getInstance()->_traceComponentMask.get())[index]=true; |
|
_traceOn = true; |
| |
// Found component, break from the loop | // Found component, break from the loop |
break; | break; |
|
|
// initialise ComponentMask array to False | // initialise ComponentMask array to False |
for (Uint32 index = 0;index < _NUM_COMPONENTS; | for (Uint32 index = 0;index < _NUM_COMPONENTS; |
(_getInstance()->_traceComponentMask.get())[index++] = false); | (_getInstance()->_traceComponentMask.get())[index++] = false); |
|
_traceOn = 0; |
} | } |
return ; | return ; |
} | } |