version 1.1.2.1, 2001/07/31 23:57:08
|
version 1.1.2.8, 2001/10/24 20:44:37
|
|
|
| |
// Set Log messages | // Set Log messages |
const char Tracer::_LOG_MSG1[] = "LEVEL1 not enabled with Tracer::trace call."; | const char Tracer::_LOG_MSG1[] = "LEVEL1 not enabled with Tracer::trace call."; |
const char Tracer::_LOG_MSG2[]="Use trace macros, PEG_FUNC_ENTER/PEG_FUNC_EXIT"; |
const char |
|
Tracer::_LOG_MSG2[] = "LEVEL1 not enabled with Tracer::traceBuffer call."; |
|
const char Tracer::_LOG_MSG3[]="Use trace macros, PEG_FUNC_ENTER/PEG_FUNC_EXIT"; |
| |
// Initialize singleton instance of Tracer | // Initialize singleton instance of Tracer |
Tracer* Tracer::_tracerInstance = 0; | Tracer* Tracer::_tracerInstance = 0; |
|
|
const Uint32 Tracer::_NUM_COMPONENTS = | const Uint32 Tracer::_NUM_COMPONENTS = |
sizeof(TRACE_COMPONENT_LIST)/sizeof(TRACE_COMPONENT_LIST[0]); | sizeof(TRACE_COMPONENT_LIST)/sizeof(TRACE_COMPONENT_LIST[0]); |
| |
|
// Set the line maximum |
|
const Uint32 Tracer::_STRLEN_MAX_UNSIGNED_INT = 21; |
|
|
//////////////////////////////////////////////////////////////////////////////// | //////////////////////////////////////////////////////////////////////////////// |
// Tracer constructor | // Tracer constructor |
// Constructor is private to preclude construction of Tracer objects | // Constructor is private to preclude construction of Tracer objects |
|
|
// ATTN: Setting the Log file type to DEBUG_LOG | // ATTN: Setting the Log file type to DEBUG_LOG |
// May need to change to an appropriate log file type | // May need to change to an appropriate log file type |
Logger::put(Logger::DEBUG_LOG,"Tracer",Logger::WARNING,"$0 $1", | Logger::put(Logger::DEBUG_LOG,"Tracer",Logger::WARNING,"$0 $1", |
_LOG_MSG1,_LOG_MSG2); |
_LOG_MSG1,_LOG_MSG3); |
} | } |
else | else |
{ | { |
|
|
if ( traceLevel == LEVEL1 ) | if ( traceLevel == LEVEL1 ) |
{ | { |
Logger::put(Logger::DEBUG_LOG,"Tracer",Logger::WARNING,"$0 $1", | Logger::put(Logger::DEBUG_LOG,"Tracer",Logger::WARNING,"$0 $1", |
_LOG_MSG1,_LOG_MSG2); |
_LOG_MSG1,_LOG_MSG3); |
} | } |
else | else |
{ | { |
if (_isTraceEnabled(traceComponent,traceLevel)) | if (_isTraceEnabled(traceComponent,traceLevel)) |
{ | { |
message = new char[strlen(fileName)+strlen(ltoa((long)lineNum))+6]; |
message = new char[ strlen(fileName) + |
|
_STRLEN_MAX_UNSIGNED_INT + 6 ]; |
sprintf(message,"[%s:%d]: ",fileName,lineNum); | sprintf(message,"[%s:%d]: ",fileName,lineNum); |
|
|
_trace(traceComponent,message,fmt,argList); | _trace(traceComponent,message,fmt,argList); |
delete []message; | delete []message; |
} | } |
|
|
} | } |
| |
//////////////////////////////////////////////////////////////////////////////// | //////////////////////////////////////////////////////////////////////////////// |
|
//Traces the given buffer |
|
//////////////////////////////////////////////////////////////////////////////// |
|
void Tracer::_traceBuffer( |
|
const Uint32 traceComponent, |
|
const Uint32 traceLevel, |
|
const char* data, |
|
const Uint32 size) |
|
{ |
|
if ( traceLevel == LEVEL1 ) |
|
{ |
|
Logger::put(Logger::DEBUG_LOG,"Tracer",Logger::WARNING,"$0 $1", |
|
_LOG_MSG2,_LOG_MSG3); |
|
} |
|
else |
|
{ |
|
if (_isTraceEnabled(traceComponent,traceLevel)) |
|
{ |
|
char* tmpBuf = new char[size+1]; |
|
|
|
strncpy( tmpBuf, data, size ); |
|
tmpBuf[size] = '\0'; |
|
_trace(traceComponent,"",tmpBuf); |
|
|
|
delete []tmpBuf; |
|
} |
|
} |
|
} |
|
//////////////////////////////////////////////////////////////////////////////// |
|
//Traces the given buffer - Overloaded for including FileName and Line number |
|
//////////////////////////////////////////////////////////////////////////////// |
|
void Tracer::_traceBuffer( |
|
const char* fileName, |
|
const Uint32 lineNum, |
|
const Uint32 traceComponent, |
|
const Uint32 traceLevel, |
|
const char* data, |
|
const Uint32 size) |
|
{ |
|
if ( traceLevel == LEVEL1 ) |
|
{ |
|
Logger::put(Logger::DEBUG_LOG,"Tracer",Logger::WARNING,"$0 $1", |
|
_LOG_MSG2,_LOG_MSG3); |
|
} |
|
else |
|
{ |
|
if ( _isTraceEnabled( traceComponent, traceLevel ) ) |
|
{ |
|
char* message = new char[ strlen(fileName) + |
|
_STRLEN_MAX_UNSIGNED_INT + 6 ]; |
|
char* tmpBuf = new char[size+1]; |
|
|
|
sprintf(message,"[%s:%d]: ",fileName,lineNum); |
|
strncpy( tmpBuf, data, size ); |
|
tmpBuf[size] = '\0'; |
|
_trace(traceComponent,message,tmpBuf); |
|
|
|
delete []tmpBuf; |
|
delete []message; |
|
} |
|
} |
|
} |
|
|
|
//////////////////////////////////////////////////////////////////////////////// |
//Traces method entry | //Traces method entry |
//////////////////////////////////////////////////////////////////////////////// | //////////////////////////////////////////////////////////////////////////////// |
void Tracer::_traceEnter( | void Tracer::_traceEnter( |
|
|
if (_isTraceEnabled(traceComponent,LEVEL1)) | if (_isTraceEnabled(traceComponent,LEVEL1)) |
{ | { |
va_start(argList,fmt); | va_start(argList,fmt); |
message = new char[strlen(fileName)+strlen(ltoa((long)lineNum))+6]; |
|
|
message = new char[ strlen(fileName) + |
|
_STRLEN_MAX_UNSIGNED_INT + 6 ]; |
sprintf(message,"[%s:%d]: ",fileName,lineNum); | sprintf(message,"[%s:%d]: ",fileName,lineNum); |
_trace(traceComponent,message,fmt,argList); | _trace(traceComponent,message,fmt,argList); |
|
|
va_end(argList); | va_end(argList); |
delete []message; | delete []message; |
} | } |
|
|
if (_isTraceEnabled(traceComponent,LEVEL1)) | if (_isTraceEnabled(traceComponent,LEVEL1)) |
{ | { |
va_start(argList,fmt); | va_start(argList,fmt); |
message = new char[strlen(fileName)+strlen(ltoa((long)lineNum))+6]; |
|
|
message = new char[ strlen(fileName) + |
|
_STRLEN_MAX_UNSIGNED_INT + 6 ]; |
sprintf(message,"[%s:%d]: ",fileName,lineNum); | sprintf(message,"[%s:%d]: ",fileName,lineNum); |
_trace(traceComponent,message,fmt,argList); | _trace(traceComponent,message,fmt,argList); |
va_end(argList); | va_end(argList); |
|
|
delete []message; | delete []message; |
} | } |
} | } |
|
|
va_list argList) | va_list argList) |
{ | { |
char* msgHeader; | char* msgHeader; |
Uint32 retCode; |
|
| |
// Get the current system time and prepend to message | // Get the current system time and prepend to message |
String currentTime = System::getCurrentASCIITime(); | String currentTime = System::getCurrentASCIITime(); |
|
|
} | } |
| |
//////////////////////////////////////////////////////////////////////////////// | //////////////////////////////////////////////////////////////////////////////// |
//Set the trace file |
//Validate the trace file |
//////////////////////////////////////////////////////////////////////////////// | //////////////////////////////////////////////////////////////////////////////// |
Uint32 Tracer::setTraceFile(const char* traceFile) |
Boolean Tracer::isValid(const char* filePath) |
{ | { |
ofstream outFile; |
return (_getInstance()->_traceHandler->isValidFilePath(filePath)); |
Uint32 retCode = 0; |
} |
|
|
// Check if the file can be opened in append mode |
|
if (traceFile) |
|
{ |
|
outFile.open(traceFile,ofstream::app); |
|
| |
if (outFile.good()) |
//////////////////////////////////////////////////////////////////////////////// |
|
//Returns the Singleton instance of the Tracer |
|
//////////////////////////////////////////////////////////////////////////////// |
|
Tracer* Tracer::_getInstance() |
{ | { |
_getInstance()->_traceHandler->setFileName (traceFile); |
if (_tracerInstance == 0) |
outFile.close(); |
|
} |
|
else |
|
{ | { |
outFile.close(); |
_tracerInstance = new Tracer(); |
retCode = 1; |
|
} | } |
|
return _tracerInstance; |
} | } |
else |
|
|
// PEGASUS_REMOVE_TRACE defines the compile time inclusion of the Trace |
|
// interfaces. If defined the interfaces map to empty functions |
|
|
|
#ifndef PEGASUS_REMOVE_TRACE |
|
|
|
//////////////////////////////////////////////////////////////////////////////// |
|
//Set the trace file |
|
//////////////////////////////////////////////////////////////////////////////// |
|
Uint32 Tracer::setTraceFile(const char* traceFile) |
{ | { |
retCode=1; |
return (_getInstance()->_traceHandler->setFileName (traceFile)); |
} |
|
return retCode; |
|
} | } |
| |
//////////////////////////////////////////////////////////////////////////////// | //////////////////////////////////////////////////////////////////////////////// |
|
|
if (traceComponents != String::EMPTY) | if (traceComponents != String::EMPTY) |
{ | { |
// Check if ALL is specified | // Check if ALL is specified |
if (traceComponents == "ALL") |
if (String::equalNoCase(traceComponents,"ALL")) |
{ | { |
for (int index=0; index < _NUM_COMPONENTS; | for (int index=0; index < _NUM_COMPONENTS; |
_getInstance()->_traceComponentMask[index++] = true); | _getInstance()->_traceComponentMask[index++] = true); |
|
|
} | } |
| |
// initialise ComponentMask array to False | // initialise ComponentMask array to False |
for (int index = 0;index < _NUM_COMPONENTS; |
for (index = 0;index < _NUM_COMPONENTS; |
_getInstance()->_traceComponentMask[index++] = false); | _getInstance()->_traceComponentMask[index++] = false); |
| |
// Append _COMPONENT_SEPARATOR to the end of the traceComponents | // Append _COMPONENT_SEPARATOR to the end of the traceComponents |
|
|
} | } |
} | } |
| |
//////////////////////////////////////////////////////////////////////////////// |
#endif |
//Returns the Singleton instance of the Tracer |
|
//////////////////////////////////////////////////////////////////////////////// |
|
Tracer* Tracer::_getInstance() |
|
{ |
|
if (_tracerInstance == 0) |
|
{ |
|
_tracerInstance = new Tracer(); |
|
} |
|
return _tracerInstance; |
|
} |
|
| |
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |