(file) Return to Tracer.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

Diff for /pegasus/src/Pegasus/Common/Tracer.cpp between version 1.23 and 1.44

version 1.23, 2004/06/22 22:06:23 version 1.44, 2007/04/03 18:50:52
Line 1 
Line 1 
 //%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
Line 23 
Line 29 
 // //
 //============================================================================== //==============================================================================
 // //
 // Author: Sushma Fernandes, Hewlett-Packard Company (sushma_fernandes@hp.com)  
 //  
 // Modified By: Jenny Yu, Hewlett-Packard Company (jenny_yu@hp.com)  
 //              Amit K Arora, IBM (amita@in.ibm.com) for PEP#101  
 //              Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)  
 //  
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
 #include <Pegasus/Common/Config.h> #include <Pegasus/Common/Config.h>
 #include <Pegasus/Common/Tracer.h> #include <Pegasus/Common/Tracer.h>
 #include <Pegasus/Common/Thread.h> #include <Pegasus/Common/Thread.h>
 #include <Pegasus/Common/IPC.h>  
 #include <Pegasus/Common/System.h> #include <Pegasus/Common/System.h>
  
 PEGASUS_USING_STD; PEGASUS_USING_STD;
Line 59 
Line 58 
 const char Tracer::_METHOD_EXIT_MSG[]  = "Exiting method"; const char Tracer::_METHOD_EXIT_MSG[]  = "Exiting method";
  
 // Set Log messages // Set Log messages
 const char Tracer::_LOG_MSG[] = "LEVEL1 may only be used with trace macros PEG_METHOD_ENTER/PEG_METHOD_EXIT.";  const char Tracer::_LOG_MSG[] =
       "LEVEL1 may only be used with trace macros "
           "PEG_METHOD_ENTER/PEG_METHOD_EXIT.";
  
 // Initialize singleton instance of Tracer // Initialize singleton instance of Tracer
 Tracer* Tracer::_tracerInstance = 0; Tracer* Tracer::_tracerInstance = 0;
Line 75 
Line 76 
 const Uint32 Tracer::_STRLEN_MAX_UNSIGNED_INT = 21; const Uint32 Tracer::_STRLEN_MAX_UNSIGNED_INT = 21;
  
 // 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 = 21;
   
   // Initialize public indicator of trace state
   Boolean Tracer::_traceOn = false;
  
 //////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
 // Tracer constructor // Tracer constructor
Line 83 
Line 87 
 // 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);
Line 108 
Line 110 
 //////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
 void Tracer::_trace( void Tracer::_trace(
     const Uint32 traceComponent,     const Uint32 traceComponent,
     const Uint32 traceLevel,  
     const char* fmt,     const char* fmt,
     va_list argList)     va_list argList)
 { {
     if ( traceLevel == LEVEL1 )  
     {  
         trace( traceComponent, Tracer::LEVEL4, "%s", _LOG_MSG );  
     }  
     else  
     {  
         if (_isTraceEnabled(traceComponent,traceLevel))  
         {  
             _trace(traceComponent,"",fmt,argList);             _trace(traceComponent,"",fmt,argList);
         }         }
     }  
 }  
  
 //////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
 //Traces the given message - Overloaded for including FileName and Line number //Traces the given message - Overloaded for including FileName and Line number
Line 132 
Line 123 
     const char* fileName,     const char* fileName,
     const Uint32 lineNum,     const Uint32 lineNum,
     const Uint32 traceComponent,     const Uint32 traceComponent,
     const Uint32 traceLevel,  
     const char* fmt,     const char* fmt,
     va_list argList)     va_list argList)
 { {
     char* message;     char* message;
   
     if ( traceLevel == LEVEL1 )  
     {  
         trace( traceComponent, Tracer::LEVEL4, "%s", _LOG_MSG );  
     }  
     else  
     {  
         if (_isTraceEnabled(traceComponent,traceLevel))  
         {  
             //             //
             // Allocate memory for the message string             // Allocate memory for the message string
             // Needs to be updated if additional info is added             // Needs to be updated if additional info is added
Line 154 
Line 135 
                 _STRLEN_MAX_UNSIGNED_INT + (_STRLEN_MAX_PID_TID * 2) + 8 ];                 _STRLEN_MAX_UNSIGNED_INT + (_STRLEN_MAX_PID_TID * 2) + 8 ];
             sprintf(             sprintf(
                message,                message,
                "[%d:%u:%s:%u]: ",         "[%d:%s:%s:%u]: ",
                System::getPID(),                System::getPID(),
                Uint32(pegasus_thread_self()),         Threads::id().buffer,
                fileName,                fileName,
                lineNum);                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 )  
     {  
         trace( traceComponent, Tracer::LEVEL4, "%s", _LOG_MSG );  
     }  
     else  
     {  
         if (_isTraceEnabled(traceComponent,traceLevel))  
         {  
             char* tmpBuf = new char[size+1];  
   
             strncpy( tmpBuf, data, size );  
             tmpBuf[size] = '\0';  
             trace(traceComponent,traceLevel,"%s",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 )  
     {  
         trace( traceComponent, Tracer::LEVEL4, "%s", _LOG_MSG );  
     }  
     else  
     {  
         if ( _isTraceEnabled( traceComponent, traceLevel ) )  
         {  
             char* tmpBuf = new char[size+1];  
   
             strncpy( tmpBuf, data, size );  
             tmpBuf[size] = '\0';  
             trace(fileName,lineNum,traceComponent,traceLevel,"%s",tmpBuf);  
   
             delete []tmpBuf;  
         }  
     }  
 }  
   
 ////////////////////////////////////////////////////////////////////////////////  
 //Traces the given string  
 ////////////////////////////////////////////////////////////////////////////////  
 void Tracer::_traceString(  
     const Uint32   traceComponent,  
     const Uint32   traceLevel,  
     const String&  traceString)  
 {  
     if ( traceLevel == LEVEL1 )  
     {  
         trace( traceComponent, Tracer::LEVEL4, "%s", _LOG_MSG );  
     }  
     else  
     {  
         if (_isTraceEnabled(traceComponent,traceLevel))  
         {  
             trace(traceComponent,traceLevel,"%s",  
                        (const char *)traceString.getCString());  
         }  
     }  
 }  
  
 //////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
 //Traces the given string - Overloaded to include the fileName and line number //Traces the given string - Overloaded to include the fileName and line number
 //of trace origin. //of trace origin.
 //////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
 void Tracer::_traceString(  void Tracer::_traceCString(
     const char*   fileName,     const char*   fileName,
     const Uint32  lineNum,     const Uint32  lineNum,
     const Uint32  traceComponent,     const Uint32  traceComponent,
     const Uint32  traceLevel,      const char* cstring)
     const String& traceString)  
 {  
     if ( traceLevel == LEVEL1 )  
     {  
         trace( traceComponent, Tracer::LEVEL4, "%s", _LOG_MSG );  
     }  
     else  
     {  
         if ( _isTraceEnabled( traceComponent, traceLevel ) )  
         {  
             trace(fileName,lineNum,traceComponent,traceLevel,"%s",  
                      (const char *)traceString.getCString());  
         }  
     }  
 }  
   
 ////////////////////////////////////////////////////////////////////////////////  
 //Traces the message in the given CIMException object.  
 ////////////////////////////////////////////////////////////////////////////////  
 void Tracer::_traceCIMException(  
     const Uint32 traceComponent,  
     const Uint32 traceLevel,  
     CIMException cimException)  
 { {
     if ( traceLevel == LEVEL1 )  
     {  
         trace( traceComponent, Tracer::LEVEL4, "%s", _LOG_MSG );  
     }  
     else  
     {  
         if ( _isTraceEnabled( traceComponent, traceLevel ) )  
         {  
             // get the CIMException trace message string  
             String traceMsg =  
                 TraceableCIMException(cimException).getTraceDescription();  
   
             // trace the string  
             _traceString(traceComponent, traceLevel, traceMsg);  
         }  
     }  
 }  
   
 ////////////////////////////////////////////////////////////////////////////////  
 //Traces method entry  
 ////////////////////////////////////////////////////////////////////////////////  
 void Tracer::_traceEnter(  
     const char* fileName,  
     const Uint32 lineNum,  
     const Uint32 traceComponent,  
     const char* fmt,  
     ...)  
 {  
     va_list argList;  
     char* message;     char* message;
  
     if (_isTraceEnabled(traceComponent,LEVEL1))  
     {  
   
         va_start(argList,fmt);  
   
         //         //
         // Allocate memory for the message string         // Allocate memory for the message string
         // Needs to be updated if additional info is added         // Needs to be updated if additional info is added
         //         //
         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 ];
   
         sprintf(         sprintf(
            message,            message,
            "[%d:%u:%s:%u]: ",         "[%d:%s:%s:%u]: ",
            System::getPID(),            System::getPID(),
            Uint32(pegasus_thread_self()),         Threads::id().buffer,
            fileName,            fileName,
            lineNum);            lineNum);
         _trace(traceComponent,message,fmt,argList);  
  
         va_end(argList);      _traceCString(traceComponent, message, cstring);
         delete []message;         delete []message;
     }     }
   
   ////////////////////////////////////////////////////////////////////////////////
   //Traces the message in the given CIMException object.
   ////////////////////////////////////////////////////////////////////////////////
   void Tracer::_traceCIMException(
       const Uint32 traceComponent,
       const CIMException& cimException)
   {
       // get the CIMException trace message string
       CString traceMsg =
           TraceableCIMException(cimException).getTraceDescription().getCString();
       // trace the string
       _traceCString(traceComponent, "", (const char*) traceMsg);
 } }
  
 //////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
 //Traces method exit  //Traces method entry and exit
 //////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
 void Tracer::_traceExit(  void Tracer::_traceMethod(
     const char* fileName,     const char* fileName,
     const Uint32 lineNum,     const Uint32 lineNum,
     const Uint32 traceComponent,     const Uint32 traceComponent,
     const char* fmt      const char* methodEntryExit,
     ...)      const char* method)
 { {
     va_list argList;  
     char* message;     char* message;
  
     if (_isTraceEnabled(traceComponent,LEVEL1))  
     {  
         va_start(argList,fmt);  
   
         //         //
         // Allocate memory for the message string         // Allocate memory for the message string
         // Needs to be updated if additional info is added         // Needs to be updated if additional info is added
         //         //
       // assume Method entry/exit string 15 characters long
       // +1 space character
         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
           + 16];
  
         sprintf(         sprintf(
            message,            message,
            "[%d:%u:%s:%u]: ",         "[%d:%s:%s:%u]: %s ",
            System::getPID(),            System::getPID(),
            Uint32(pegasus_thread_self()),         Threads::id().buffer,
            fileName,            fileName,
            lineNum);         lineNum,
         _trace(traceComponent,message,fmt,argList);         methodEntryExit);
         va_end(argList);  
       _traceCString(traceComponent, message, method);
  
         delete []message;         delete []message;
     }     }
 }  
  
 //////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
 //Checks if trace is enabled for the given component and level //Checks if trace is enabled for the given component and level
 //////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
 Boolean Tracer::_isTraceEnabled(const Uint32 traceComponent,  Boolean Tracer::_isTraceEnabled(
       const Uint32 traceComponent,
     const Uint32 traceLevel)     const Uint32 traceLevel)
 { {
     Tracer* instance = _getInstance();     Tracer* instance = _getInstance();
Line 389 
Line 243 
 } }
  
 //////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
 //Called by all trace interfaces to log message to trace file  //Called by all trace interfaces with variable arguments
   //to log message to trace file
 //////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
 void Tracer::_trace( void Tracer::_trace(
     const Uint32 traceComponent,     const Uint32 traceComponent,
Line 408 
Line 263 
     // Needs to be updated if additional info is added     // Needs to be updated if additional info is added
     //     //
  
   
   
     // 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
        msgHeader = new char [strlen(message)         // in this format string
                              + strlen(TRACE_COMPONENT_LIST[traceComponent])         msgHeader = new char [strlen(message) +
                              + strlen(timeStamp) + _STRLEN_MAX_PID_TID + 5];             strlen(TRACE_COMPONENT_LIST[traceComponent]) +
              strlen(timeStamp) + _STRLEN_MAX_PID_TID + 5];
  
         sprintf(msgHeader,"%s: %s %s",(const char*)timeStamp,         sprintf(msgHeader,"%s: %s %s",(const char*)timeStamp,
             TRACE_COMPONENT_LIST[traceComponent] ,message);             TRACE_COMPONENT_LIST[traceComponent] ,message);
         //delete [] msgHeader;  
     }     }
     else     else
     {     {
         //         //
         // Since the message is blank form a string using the pid and tid          // Since the message is blank, form a string using the pid and tid
         //         //
         char*  tmpBuffer;         char*  tmpBuffer;
  
Line 435 
Line 288 
         // Allocate messageHeader.         // Allocate messageHeader.
         // 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[2 * _STRLEN_MAX_PID_TID + 6];
         sprintf(tmpBuffer, "[%u:%u]: ", System::getPID(),          sprintf(tmpBuffer, "[%u:%s]: ",
                 Uint32(pegasus_thread_self()));              System::getPID(), Threads::id().buffer);
         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 ];
  
         sprintf(msgHeader,"%s: %s %s ",(const char*)timeStamp,         sprintf(msgHeader,"%s: %s %s ",(const char*)timeStamp,
             TRACE_COMPONENT_LIST[traceComponent] ,tmpBuffer );             TRACE_COMPONENT_LIST[traceComponent] ,tmpBuffer );
         delete []tmpBuffer;         delete []tmpBuffer;
         //delete [] msgHeader;  
   
     }     }
  
     // Call trace file handler to write message     // Call trace file handler to write message
Line 455 
Line 307 
 } }
  
 //////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
   //Called by all trace interfaces using a character string without format string
   //to log message to trace file
   ////////////////////////////////////////////////////////////////////////////////
   void Tracer::_traceCString(
       const Uint32 traceComponent,
       const char* message,
       const char* cstring)
   {
       char* completeMessage;
   
       // Get the current system time and prepend to message
       String currentTime = System::getCurrentASCIITime();
       CString timeStamp = currentTime.getCString();
       //
       // Allocate completeMessage.
       // Needs to be updated if additional info is added
       //
   
       // Construct the message header
       // The message header is in the following format
       // timestamp: <component name> [file name:line number]
       if (*message != '\0')
       {
          // << Wed Jul 16 10:58:40 2003 mdd >> _STRLEN_MAX_PID_TID is not used
          // in this format string
          completeMessage = new char [strlen(message) +
              strlen(TRACE_COMPONENT_LIST[traceComponent]) +
              strlen(timeStamp) + _STRLEN_MAX_PID_TID + 5 +
              strlen(cstring) ];
   
           sprintf(completeMessage, "%s: %s %s%s", (const char*)timeStamp,
               TRACE_COMPONENT_LIST[traceComponent], message, cstring);
       }
       else
       {
           //
           // Since the message is blank, form a string using the pid and tid
           //
           char* tmpBuffer;
   
           //
           // Allocate messageHeader.
           // Needs to be updated if additional info is added
           //
           tmpBuffer = new char[2 * _STRLEN_MAX_PID_TID + 6];
           sprintf(tmpBuffer, "[%u:%s]: ",
               System::getPID(), Threads::id().buffer);
   
           completeMessage = new char[strlen(timeStamp) +
               strlen(TRACE_COMPONENT_LIST[traceComponent]) +
               strlen(tmpBuffer) + 1  + 5 +
               strlen(cstring)];
   
           sprintf(completeMessage, "%s: %s %s %s", (const char*)timeStamp,
               TRACE_COMPONENT_LIST[traceComponent], tmpBuffer, cstring);
           delete [] tmpBuffer;
       }
   
       // Call trace file handler to write message
       _getInstance()->_traceHandler->handleMessage(completeMessage);
   
       delete [] completeMessage;
   }
   
   
   ////////////////////////////////////////////////////////////////////////////////
 //Validate the trace file //Validate the trace file
 //////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
 Boolean Tracer::isValidFileName(const char* filePath) Boolean Tracer::isValidFileName(const char* filePath)
Line 462 
Line 380 
     String moduleName = _getInstance()->_moduleName;     String moduleName = _getInstance()->_moduleName;
     if (moduleName == String::EMPTY)     if (moduleName == String::EMPTY)
     {     {
         return (_getInstance()->_traceHandler->isValidFilePath(filePath));          return _getInstance()->_traceHandler->isValidFilePath(filePath);
     }     }
     else     else
     {     {
         String extendedFilePath = String(filePath) + "." + moduleName;         String extendedFilePath = String(filePath) + "." + moduleName;
         return (_getInstance()->_traceHandler->isValidFilePath(          return _getInstance()->_traceHandler->isValidFilePath(
             extendedFilePath.getCString()));              extendedFilePath.getCString());
     }     }
 } }
  
Line 482 
Line 400 
 } }
  
 Boolean Tracer::isValidComponents( Boolean Tracer::isValidComponents(
     const String& traceComponents, String& invalidComponents)      const String& traceComponents,
       String& invalidComponents)
 { {
     // Validate the trace components and modify the traceComponents argument     // Validate the trace components and modify the traceComponents argument
     // to reflect the invalid components     // to reflect the invalid components
  
     Uint32    position=0;     Uint32    position=0;
     Uint32    index=0;     Uint32    index=0;
     String    componentName = String::EMPTY;      String    componentName;
     String    componentStr = String::EMPTY;      String    componentStr;
     Boolean   validComponent=false;     Boolean   validComponent=false;
     Boolean   retCode=true;     Boolean   retCode=true;
  
Line 551 
Line 470 
         // trace components is empty, it is a valid value so return true         // trace components is empty, it is a valid value so return true
         return _SUCCESS;         return _SUCCESS;
     }     }
   
     if ( invalidComponents != String::EMPTY )     if ( invalidComponents != String::EMPTY )
     {     {
         retCode = false;         retCode = false;
Line 584 
Line 504 
 } }
  
 // PEGASUS_REMOVE_TRACE defines the compile time inclusion of the Trace // PEGASUS_REMOVE_TRACE defines the compile time inclusion of the Trace
 // interfaces. If defined the interfaces map to empty functions  // interfaces. This section defines the trace functions IF the remove
   // trace flag is NOT set.  If it is set, they are defined as empty functions
   // in the header file.
  
 #ifndef PEGASUS_REMOVE_TRACE #ifndef PEGASUS_REMOVE_TRACE
  
Line 593 
Line 515 
 //////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
 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)
     {     {
         return (_getInstance()->_traceHandler->setFileName(traceFile));          return _getInstance()->_traceHandler->setFileName(traceFile);
     }     }
     else     else
     {     {
         String extendedTraceFile = String(traceFile) + "." + moduleName;         String extendedTraceFile = String(traceFile) + "." + moduleName;
         return (_getInstance()->_traceHandler->setFileName(          return _getInstance()->_traceHandler->setFileName(
             extendedTraceFile.getCString()));              extendedTraceFile.getCString());
     }     }
 } }
  
Line 645 
Line 572 
 { {
     Uint32 position          = 0;     Uint32 position          = 0;
     Uint32 index             = 0;     Uint32 index             = 0;
     String componentName     = String::EMPTY;      String componentName;
     String componentStr      = traceComponents;     String componentStr      = traceComponents;
     String invalidComponents = String::EMPTY;      String invalidComponents;
  
     if (componentStr != String::EMPTY)     if (componentStr != String::EMPTY)
     {     {
         // Check if ALL is specified         // Check if ALL is specified
         if (String::equalNoCase(componentStr,"ALL"))         if (String::equalNoCase(componentStr,"ALL"))
         {         {
             for (index=0; index < _NUM_COMPONENTS;              for (index = 0; index < _NUM_COMPONENTS; index++)
                     (_getInstance()->_traceComponentMask.get())[index++] = true);              {
                   (_getInstance()->_traceComponentMask.get())[index] = true;
               }
               _traceOn = true;
             return ;             return ;
         }         }
  
         // initialise ComponentMask array to False          // initialize ComponentMask array to False
         for (index = 0;index < _NUM_COMPONENTS;          for (index = 0; index < _NUM_COMPONENTS; index++)
                 (_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);
Line 681 
Line 614 
                        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;
Line 698 
Line 632 
     else     else
     {     {
         // initialise ComponentMask array to False         // initialise ComponentMask array to False
         for (Uint32 index = 0;index < _NUM_COMPONENTS;          for (Uint32 index = 0;index < _NUM_COMPONENTS; index++)
                  (_getInstance()->_traceComponentMask.get())[index++] = false);          {
               (_getInstance()->_traceComponentMask.get())[index] = false;
           }
           _traceOn = 0;
     }     }
     return ;     return ;
 } }
  
 #endif  void Tracer::traceEnter(
       TracerToken& token,
       const char* file,
       size_t line,
       Uint32 traceComponent,
       const char* method)
   {
       token.component = traceComponent;
       token.method = method;
   
       if (_isTraceEnabled(traceComponent, LEVEL1))
       {
           _traceMethod(
               file, (Uint32)line, traceComponent,
               _METHOD_ENTER_MSG, method);
       }
   }
   
   void Tracer::traceExit(
       TracerToken& token,
       const char* file,
       size_t line)
   {
       if (_isTraceEnabled(token.component, LEVEL1))
           _traceMethod(
               file, (Uint32)line, token.component,
               _METHOD_EXIT_MSG, token.method);
   }
   
   void Tracer::trace(
       const Uint32 traceComponent,
       const Uint32 traceLevel,
       const char *fmt,
       ...)
   {
       PEGASUS_ASSERT(traceLevel != LEVEL1);
       if (_isTraceEnabled(traceComponent, traceLevel))
       {
           va_list argList;
           va_start(argList,fmt);
           _trace(traceComponent,fmt,argList);
           va_end(argList);
       }
   }
   
   void Tracer::trace(
       const char* fileName,
       const Uint32 lineNum,
       const Uint32 traceComponent,
       const Uint32 traceLevel,
       const char* fmt,
       ...)
   {
       PEGASUS_ASSERT(traceLevel != LEVEL1);
       if (_isTraceEnabled(traceComponent, traceLevel))
       {
           va_list argList;
   
           va_start(argList,fmt);
           _trace(fileName,lineNum,traceComponent,fmt,argList);
           va_end(argList);
       }
   }
   
   void Tracer::traceString(
       const char* fileName,
       const Uint32 lineNum,
       const Uint32 traceComponent,
       const Uint32 traceLevel,
       const String& string)
   {
       PEGASUS_ASSERT(traceLevel != LEVEL1);
       if (_isTraceEnabled(traceComponent, traceLevel))
       {
           _traceCString(
               fileName,
               lineNum,
               traceComponent,
               (const char*) string.getCString());
       }
   }
   
   void Tracer::traceCString(
       const char* fileName,
       const Uint32 lineNum,
       const Uint32 traceComponent,
       const Uint32 traceLevel,
       const char* cstring)
   {
       PEGASUS_ASSERT(traceLevel != LEVEL1);
       if (_isTraceEnabled(traceComponent, traceLevel))
       {
           _traceCString(
               fileName, lineNum, traceComponent, cstring);
       }
   }
   
   void Tracer::traceCIMException(
       const Uint32 traceComponent,
       const Uint32 traceLevel,
       const CIMException& cimException)
   {
       PEGASUS_ASSERT(traceLevel != LEVEL1);
       if (_isTraceEnabled(traceComponent, traceLevel))
       {
           _traceCIMException(traceComponent, cimException);
       }
   }
   
   #endif /* !PEGASUS_REMOVE_TRACE */
  
 PEGASUS_NAMESPACE_END PEGASUS_NAMESPACE_END


Legend:
Removed from v.1.23  
changed lines
  Added in v.1.44

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2