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

Diff for /pegasus/src/Pegasus/Common/Logger.cpp between version 1.56 and 1.57

version 1.56, 2007/09/12 21:30:58 version 1.57, 2007/10/17 20:37:27
Line 72 
Line 72 
  
 const Uint32 Logger::_NUM_LOGLEVEL = 5; const Uint32 Logger::_NUM_LOGLEVEL = 5;
  
 // Set separator  
 const char Logger::_SEPARATOR = '@';  
   
 Uint32 Logger::_severityMask; Uint32 Logger::_severityMask;
  
 Uint32 Logger::_writeControlMask = 0xF;   // Set all on by default  ///////////////////////////////////////////////////////////////////////////////
   //
   // LoggerRep
   //
   ///////////////////////////////////////////////////////////////////////////////
   
   #if defined(PEGASUS_USE_SYSLOGS)
   
   class LoggerRep
   {
   public:
   
       LoggerRep(const String& homeDirectory)
       {
   # ifdef PEGASUS_OS_ZOS
           logIdentity = strdup(System::CIMSERVER.getCString());
           // If System Log is used open it
           System::openlog(logIdentity, LOG_PID, LOG_DAEMON);
   # endif
       }
   
       ~LoggerRep()
       {
   # ifdef PEGASUS_OS_ZOS
           System::closelog();
           free(logIdentity);
   # endif
       }
   
       // Actual logging is done in this routine
       void log(Logger::LogFileType logFileType,
           const String& systemId,
           Uint32 logLevel,
           const String localizedMsg)
       {
           // Log the message
           System::syslog(systemId, logLevel, localizedMsg.getCString());
       }
   
   private:
   
   # ifdef PEGASUS_OS_ZOS
       char* logIdentity;
   # endif
   };
  
 // Set the return codes  #else    // !defined(PEGASUS_USE_SYSLOGS)
 const Boolean Logger::_SUCCESS = 1;  
 const Boolean Logger::_FAILURE = 0;  
  
     static const char* fileNames[] =     static const char* fileNames[] =
     {     {
Line 93 
Line 132 
     };     };
 static const char* lockFileName =  "PegasusLog.lock"; static const char* lockFileName =  "PegasusLog.lock";
  
   /*
 /* _constructFileName prepares the absolute file name from homeDirectory      _constructFileName builds the absolute file name from homeDirectory
     and fileName.     and fileName.
   
     Today this is static.  However, it should be completely  
     configerable and driven from the config file so that  
     Log organization and names are open.  
     ATTN: rewrite this so that names, choice to do logs and  
     mask for level of severity are all driven from configuration  
     input.  
 */ */
 static CString _constructFileName( static CString _constructFileName(
     const String& homeDirectory,     const String& homeDirectory,
     const char * fileName)     const char * fileName)
 { {
     String result;     String result;
     result.reserveCapacity((Uint32)(homeDirectory.size() + 1 +      result.reserveCapacity(
         strlen(fileName)));          (Uint32)(homeDirectory.size() + 1 + strlen(fileName)));
     result.append(homeDirectory);     result.append(homeDirectory);
     result.append('/');     result.append('/');
     result.append(fileName);     result.append(fileName);
Line 123 
Line 155 
  
     LoggerRep(const String& homeDirectory)     LoggerRep(const String& homeDirectory)
     {     {
 #if !defined(PEGASUS_USE_SYSLOGS)  
         // Add test for home directory set.         // Add test for home directory set.
  
         // If home directory does not exist, create it.         // If home directory does not exist, create it.
Line 156 
Line 187 
         }         }
 #endif #endif
  
   
         _logFileNames[Logger::TRACE_LOG] = _constructFileName(homeDirectory,         _logFileNames[Logger::TRACE_LOG] = _constructFileName(homeDirectory,
                                                fileNames[Logger::TRACE_LOG]);                                                fileNames[Logger::TRACE_LOG]);
  
Line 173 
Line 203 
  
         _logFileNames[Logger::DEBUG_LOG] = _constructFileName(homeDirectory,         _logFileNames[Logger::DEBUG_LOG] = _constructFileName(homeDirectory,
                                                fileNames[Logger::DEBUG_LOG]);                                                fileNames[Logger::DEBUG_LOG]);
 #else  
   
 #ifdef PEGASUS_OS_ZOS  
        logIdentity = strdup(System::CIMSERVER.getCString());  
         // If System Log is used open it  
         System::openlog(logIdentity, LOG_PID, LOG_DAEMON);  
 #endif  
   
 #endif  
   
     }     }
  
     ~LoggerRep()     ~LoggerRep()
     {     {
   
 #ifdef PEGASUS_OS_ZOS  
         System::closelog();  
         free(logIdentity);  
 #endif  
     }     }
  
     // Actual logging is done in this routine     // Actual logging is done in this routine
Line 200 
Line 215 
         Uint32 logLevel,         Uint32 logLevel,
         const String localizedMsg)         const String localizedMsg)
     {     {
 #if defined(PEGASUS_USE_SYSLOGS)  
   
         // Log the message  
         System::syslog(systemId, logLevel, localizedMsg.getCString());  
   
 #else  
         // Prepend the systemId to the incoming message         // Prepend the systemId to the incoming message
         String messageString(systemId);         String messageString(systemId);
         messageString.append(": ");         messageString.append(": ");
Line 276 
Line 285 
         logFileStream << System::getCurrentASCIITime()         logFileStream << System::getCurrentASCIITime()
            << " " << tmp << (const char *)messageString.getCString() << endl;            << " " << tmp << (const char *)messageString.getCString() << endl;
         logFileStream.close();         logFileStream.close();
 #endif // ifndef PEGASUS_USE_SYSLOGS  
     }     }
  
 private: private:
  
 #ifdef PEGASUS_OS_ZOS  
     char* logIdentity;  
 #endif  
     CString _logFileNames[int(Logger::NUM_LOGS)];     CString _logFileNames[int(Logger::NUM_LOGS)];
   
 #ifndef PEGASUS_OS_VMS #ifndef PEGASUS_OS_VMS
     CString _loggerLockFileName;     CString _loggerLockFileName;
     Mutex _mutex;     Mutex _mutex;
 #endif #endif
 }; };
  
   #endif    // !defined(PEGASUS_USE_SYSLOGS)
   
   
   ///////////////////////////////////////////////////////////////////////////////
   //
   // Logger
   //
   ///////////////////////////////////////////////////////////////////////////////
   
 void Logger::_putInternal( void Logger::_putInternal(
     LogFileType logFileType,     LogFileType logFileType,
     const String& systemId,     const String& systemId,
Line 799 
Line 814 
     else     else
     {     {
         // logLevels is empty, it is a valid value so return true         // logLevels is empty, it is a valid value so return true
         return _SUCCESS;          return true;
     }     }
  
     return validlogLevel;     return validlogLevel;


Legend:
Removed from v.1.56  
changed lines
  Added in v.1.57

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2