(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.22 and 1.31

version 1.22, 2004/06/03 15:04:54 version 1.31, 2005/11/21 08:37:44
Line 1 
Line 1 
 //%2003////////////////////////////////////////////////////////////////////////  //%2005////////////////////////////////////////////////////////////////////////
 // //
 // 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.
 // //
 // 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 27 
Line 31 
 // //
 // 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)
   //              Josephine Eskaline Joyce, IBM (jojustin@in.ibm.com) for Bug#2498
   //              Sean Keenan, Hewlett-Packard Company (sean.keenan@hp.com)
 // //
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
Line 76 
Line 83 
 // 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
   Uint32 Tracer::_traceOn=0;
   
 //////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
 // Tracer constructor // Tracer constructor
 // Constructor is private to preclude construction of Tracer objects // Constructor is private to preclude construction of Tracer objects
Line 153 
Line 163 
                 _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);
  
Line 320 
Line 340 
         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]: ",
Line 327 
Line 359 
            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);
Line 358 
Line 391 
         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]: ",
Line 365 
Line 410 
            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);
  
Line 412 
Line 458 
     // 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)
Line 435 
Line 481 
         // 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 ];
  
Line 458 
Line 512 
 //////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
 Boolean Tracer::isValidFileName(const char* filePath) Boolean Tracer::isValidFileName(const char* filePath)
 { {
       String moduleName = _getInstance()->_moduleName;
       if (moduleName == String::EMPTY)
       {
     return (_getInstance()->_traceHandler->isValidFilePath(filePath));     return (_getInstance()->_traceHandler->isValidFilePath(filePath));
 } }
       else
       {
           String extendedFilePath = String(filePath) + "." + moduleName;
           return (_getInstance()->_traceHandler->isValidFilePath(
               extendedFilePath.getCString()));
       }
   }
  
 //////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
 //Validate the trace components //Validate the trace components
 //////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
 Boolean Tracer::isValidComponents(const String traceComponents)  Boolean Tracer::isValidComponents(const String& traceComponents)
 { {
     String invalidComponents;     String invalidComponents;
     return isValidComponents(traceComponents, invalidComponents);     return isValidComponents(traceComponents, invalidComponents);
 } }
  
 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
Line 553 
Line 617 
 } }
  
 //////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
   //Set the name of the module being traced
   ////////////////////////////////////////////////////////////////////////////////
   void Tracer::setModuleName(const String& moduleName)
   {
       _getInstance()->_moduleName = moduleName;
   }
   
   ////////////////////////////////////////////////////////////////////////////////
 //Returns the Singleton instance of the Tracer //Returns the Singleton instance of the Tracer
 //////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
 Tracer* Tracer::_getInstance() Tracer* Tracer::_getInstance()
Line 574 
Line 646 
 //////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
 Uint32 Tracer::setTraceFile(const char* traceFile) Uint32 Tracer::setTraceFile(const char* traceFile)
 { {
       if (*traceFile == 0)
       {
           return 1;
       }
   
       String moduleName = _getInstance()->_moduleName;
       if (moduleName == String::EMPTY)
       {
     return (_getInstance()->_traceHandler->setFileName (traceFile));     return (_getInstance()->_traceHandler->setFileName (traceFile));
 } }
       else
       {
           String extendedTraceFile = String(traceFile) + "." + moduleName;
           return (_getInstance()->_traceHandler->setFileName(
               extendedTraceFile.getCString()));
       }
   }
  
 //////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
 //Set the trace level //Set the trace level
Line 612 
Line 699 
 //////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
 // Set components to be traced. // Set components to be traced.
 //////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
 void Tracer::setTraceComponents( const String traceComponents )  void Tracer::setTraceComponents(const String& traceComponents)
 { {
     Uint32 position          = 0;     Uint32 position          = 0;
     Uint32 index             = 0;     Uint32 index             = 0;
Line 627 
Line 714 
         {         {
             for (index=0; index < _NUM_COMPONENTS;             for (index=0; index < _NUM_COMPONENTS;
                     (_getInstance()->_traceComponentMask.get())[index++] = true);                     (_getInstance()->_traceComponentMask.get())[index++] = true);
               _traceOn = 1;
             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 = 0;
  
         // 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 652 
Line 741 
                        componentName,TRACE_COMPONENT_LIST[index]))                        componentName,TRACE_COMPONENT_LIST[index]))
                 {                 {
                     (_getInstance()->_traceComponentMask.get())[index]=true;                     (_getInstance()->_traceComponentMask.get())[index]=true;
                       _traceOn = 1;
  
                     // Found component, break from the loop                     // Found component, break from the loop
                     break;                     break;
Line 671 
Line 761 
         // 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 ;
 } }


Legend:
Removed from v.1.22  
changed lines
  Added in v.1.31

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2