(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.60 and 1.74

version 1.60, 2008/12/02 09:00:53 version 1.74, 2014/12/15 16:41:18
Line 63 
Line 63 
  
        Tracer::setTraceComponents("Config,Repository");        Tracer::setTraceComponents("Config,Repository");
 */ */
 static char const* TRACE_COMPONENT_LIST[] =  char const* Tracer::TRACE_COMPONENT_LIST[] =
 { {
     "Xml",     "Xml",
     "XmlIO",     "XmlIO",
Line 84 
Line 84 
     "ObjectResolution",     "ObjectResolution",
     "WQL",     "WQL",
     "CQL",     "CQL",
       "FQL",
     "Thread",     "Thread",
     "CIMExportRequestDispatcher",     "CIMExportRequestDispatcher",
     "SSL",     "SSL",
Line 101 
Line 102 
     "IndicationReceipt",     "IndicationReceipt",
     "CMPIProviderInterface",     "CMPIProviderInterface",
     "WsmServer",     "WsmServer",
     "LogMessages"      "RsServer",
   #ifdef PEGASUS_ENABLE_PROTOCOL_WEB
       "WebServer",
   #endif
       "LogMessages",
       "WMIMapperConsumer",
       "InternalProvider",
       "EnumContext"
 }; };
  
   // Set the number of defined components
   const Uint32 Tracer::_NUM_COMPONENTS =
       sizeof(TRACE_COMPONENT_LIST)/sizeof(TRACE_COMPONENT_LIST[0]);
   
  
 // Defines the value values for trace facilities // Defines the value values for trace facilities
 // Keep the TRACE_FACILITY_LIST in sync with the TRACE_FACILITY_INDEX, // Keep the TRACE_FACILITY_LIST in sync with the TRACE_FACILITY_INDEX,
Line 138 
Line 150 
 // Set component separator // Set component separator
 const char Tracer::_COMPONENT_SEPARATOR = ','; const char Tracer::_COMPONENT_SEPARATOR = ',';
  
 // Set the number of defined components  
 const Uint32 Tracer::_NUM_COMPONENTS =  
     sizeof(TRACE_COMPONENT_LIST)/sizeof(TRACE_COMPONENT_LIST[0]);  
   
 // Set the line maximum // Set the line maximum
 const Uint32 Tracer::_STRLEN_MAX_UNSIGNED_INT = 21; const Uint32 Tracer::_STRLEN_MAX_UNSIGNED_INT = 21;
  
Line 301 
Line 309 
     _traceCString(traceComponent, "", (const char*) traceMsg);     _traceCString(traceComponent, "", (const char*) traceMsg);
 } }
  
   char* Tracer::_formatHexDump(
       char* targetBuffer,
       const char * data,
       Uint32 size)
   {
       unsigned char* p = (unsigned char*)data;
       unsigned char buf[16];
       size_t n = 0;
       int len;
   
       for (size_t i = 0, col = 0; i < size; i++)
       {
           unsigned char c = p[i];
           buf[n++] = c;
   
           if (col == 0)
           {
               len = sprintf(targetBuffer, "%06X ", (unsigned int)i);
               targetBuffer+=len;
           }
   
           len = sprintf(targetBuffer, "%02X", c);
           targetBuffer+=len;
   
           if ( ((col+1) & 3) == 0 )
           {
               *targetBuffer = ' ';
               targetBuffer++;
           }
           if (col + 1 == sizeof(buf) || i + 1 == size)
           {
               for (size_t j = col + 1; j < sizeof(buf); j++)
               {
                   targetBuffer[0]=' ';
                   targetBuffer[1]=' ';
                   targetBuffer[2]=' ';
                   targetBuffer += 3;
               }
               for (size_t j = 0; j < n; j++)
               {
                   c = buf[j];
   
                   if (c >= ' ' && c <= '~')
                   {
                       *targetBuffer = c;
                   }
                   else
                   {
                       *targetBuffer = '.';
                   }
                   targetBuffer++;
               }
               *targetBuffer = '\n';
               targetBuffer++;
               n = 0;
           }
           if (col + 1 == sizeof(buf))
           {
               col = 0;
           }
           else
           {
               col++;
           }
       }
       *targetBuffer = '\n';
       targetBuffer++;
       return targetBuffer;
   }
   
   SharedArrayPtr<char> Tracer::traceFormatChars(
       const Buffer& data,
       bool binary)
   {
       static char start[]="\n### Begin of binary data\n";
       static char end[]="\n### End of binary data\n";
       static char msg[] ="\n### Parts of data omitted. Only first 768 bytes and "\
           "last 256 bytes shown. For complete information, use traceLevel 5.\n\n";
   
       SharedArrayPtr<char> outputBuffer(
           new char[(10*data.size()+sizeof(start)+sizeof(end)+sizeof(msg))]);
   
       char* target = outputBuffer.get();
       size_t size = data.size();
   
       if (0 == size)
       {
           target[0] = 0;
           return outputBuffer;
       }
       if (binary)
       {
           memcpy(target,&(start[0]),sizeof(start)-1);
           target+=sizeof(start)-1;
           // If there are more then 1024 bytes of binary data and the trace level
           // is not at highest level(5), we only trace part of the data and not
           // everything
           if ((_traceLevelMask & Tracer::LEVEL5) || (size <= 1024))
           {
               target=_formatHexDump(target, data.getData(), size);
   
           }
           else
           {
               target=_formatHexDump(target, data.getData(), 768);
   
               memcpy(target, &(msg[0]), sizeof(msg)-1);
               target+=sizeof(msg)-1;
   
               target=_formatHexDump(target, &(data.getData()[size-256]), 256);
           }
           memcpy(target,&(end[0]),sizeof(end));
       }
       else
       {
           memcpy(target, data.getData(), size);
           target[size] = 0;
       }
       return outputBuffer;
   }
   
 SharedArrayPtr<char> Tracer::getHTTPRequestMessage( SharedArrayPtr<char> Tracer::getHTTPRequestMessage(
     const Buffer& requestMessage)     const Buffer& requestMessage)
 { {
     const Uint32 requestSize = requestMessage.size();     const Uint32 requestSize = requestMessage.size();
  
       // Check if requestMessage contains "application/x-openpegasus"
       // and if true format the the requestBuf as HexDump for tracing
       //
       // Binary is only possible on localConnect and doesn't have Basic
       // authorization for that reason
       if (strstr(requestMessage.getData(),"application/x-openpegasus"))
       {
           return traceFormatChars(requestMessage,true);
       }
   
     // Make a copy of the request message.     // Make a copy of the request message.
     SharedArrayPtr<char>     SharedArrayPtr<char>
         requestBuf(new char [requestSize + 1]);         requestBuf(new char [requestSize + 1]);
Line 319 
Line 458 
     char* sep;     char* sep;
     const char* line = requestBuf.get();     const char* line = requestBuf.get();
  
     while ((sep = HTTPMessage::findSeparator(      while ((sep = HTTPMessage::findSeparator(line)) && (line != sep))
         line, (Uint32)(requestSize - (line - requestBuf.get())))) &&  
         (line != sep))  
     {     {
         if (HTTPMessage::expectHeaderToken(line, "Authorization") &&         if (HTTPMessage::expectHeaderToken(line, "Authorization") &&
              HTTPMessage::expectHeaderToken(line, ":") &&              HTTPMessage::expectHeaderToken(line, ":") &&
Line 331 
Line 468 
             HTTPMessage::skipHeaderWhitespace(line);             HTTPMessage::skipHeaderWhitespace(line);
             for ( char* userpass = (char*)line ;             for ( char* userpass = (char*)line ;
                 userpass < sep;                 userpass < sep;
                 *userpass = 'X', userpass++);                  *userpass = 'X', userpass++)
               {
               }
             break;             break;
         }         }
  
         line = sep + ((*sep == '\r') ? 2 : 1);         line = sep + ((*sep == '\r') ? 2 : 1);
     }     }
   
     return requestBuf;     return requestBuf;
 } }
  
Line 476 
Line 613 
     else     else
     {     {
         //         //
         // Since the message is blank, form a string using the pid and tid  
         //  
         char* tmpBuffer;  
   
         //  
         // Allocate messageHeader.         // Allocate messageHeader.
         // Needs to be updated if additional info is added         // Needs to be updated if additional info is added
         //         //
Line 972 
Line 1104 
  
 #endif /* !PEGASUS_REMOVE_TRACE */ #endif /* !PEGASUS_REMOVE_TRACE */
  
   //set the trace file size only when the tracing is on a file
   void Tracer::setMaxTraceFileSize(const String &size)
   {
       Tracer *inst = _getInstance();
       if ( inst->getTraceFacility() == TRACE_FACILITY_FILE )
       {
           Uint32 traceFileSizeKBytes = 0;
           tracePropertyToUint32(size, traceFileSizeKBytes);
   
           //Safe to typecast here as we know that handler is of type file
           TraceFileHandler *hdlr = (TraceFileHandler*) (inst->_traceHandler);
   
           hdlr->setMaxTraceFileSize(traceFileSizeKBytes*1024);
   
       }
   }
   
   //set the trace file number for rolling only when the tracing is on a file
   void Tracer::setMaxTraceFileNumber(const String &maxTraceFileNumber)
   {
       Tracer *inst = _getInstance();
   
       if ( inst->getTraceFacility() == TRACE_FACILITY_FILE )
       {
           Uint32 numberOfTraceFiles = 0;
           tracePropertyToUint32(maxTraceFileNumber, numberOfTraceFiles);
   
           //Safe to typecast here as we know that handler is of type file
           TraceFileHandler *hdlr = (TraceFileHandler*) (inst->_traceHandler);
   
           hdlr->setMaxTraceFileNumber(numberOfTraceFiles);
        }
   }
   
   //
   // Converts the quantifiable trace  proprties string into a Uint32 value.
   // It returns false and the bufferSize is set to 0 if the string was not valid.
   //
   Boolean Tracer::tracePropertyToUint32(
       const String& traceProperty, Uint32& valueInUint32 )
   {
       Boolean retCode = false;
       Uint64 uInt64BufferSize;
   
       valueInUint32 = 0;
       CString stringBufferSize = traceProperty.getCString();
   
   
       retCode = StringConversion::decimalStringToUint64(stringBufferSize,
                                                         uInt64BufferSize);
   
       if (retCode )
       {
           retCode = StringConversion::checkUintBounds(uInt64BufferSize,
                                                       CIMTYPE_UINT32);
       }
   
       if (retCode )
       {
           valueInUint32 = (Uint32)uInt64BufferSize;
       }
   
       return retCode;
   }
   
   
 PEGASUS_NAMESPACE_END PEGASUS_NAMESPACE_END


Legend:
Removed from v.1.60  
changed lines
  Added in v.1.74

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2