version 1.47, 2006/11/08 20:38:30
|
version 1.51, 2007/02/06 19:07:10
|
|
|
#include <cstring> | #include <cstring> |
#include "Logger.h" | #include "Logger.h" |
#include "System.h" | #include "System.h" |
#include <Pegasus/Common/MessageLoader.h> //l10n |
#include <Pegasus/Common/MessageLoader.h> |
| |
#if defined(PEGASUS_USE_SYSLOGS) | #if defined(PEGASUS_USE_SYSLOGS) |
# include <syslog.h> | # include <syslog.h> |
|
|
| |
int index = int(logFileType); | int index = int(logFileType); |
| |
if (index > Logger::NUM_LOGS) |
if (index >= Logger::NUM_LOGS) |
index = Logger::ERROR_LOG; | index = Logger::ERROR_LOG; |
| |
const char* logFileName = fileNames[index]; | const char* logFileName = fileNames[index]; |
| |
String result; | String result; |
result.reserveCapacity(homeDirectory.size() + 1 + strlen(logFileName)); |
result.reserveCapacity((Uint32)(homeDirectory.size() + 1 + |
|
strlen(logFileName))); |
result.append(homeDirectory); | result.append(homeDirectory); |
result.append('/'); | result.append('/'); |
result.append(logFileName); | result.append(logFileName); |
|
|
| |
// KS: I put the second test in just in case some trys to create | // KS: I put the second test in just in case some trys to create |
// a completly erronous directory. At least we will get a message | // a completly erronous directory. At least we will get a message |
if (!System::isDirectory(lgDir)){ |
if (!System::isDirectory(lgDir)) |
//l10n |
{ |
//cerr << "Logging Disabled"; |
|
MessageLoaderParms parms("Common.Logger.LOGGING_DISABLED", | MessageLoaderParms parms("Common.Logger.LOGGING_DISABLED", |
"Logging Disabled"); | "Logging Disabled"); |
| |
|
|
#else | #else |
| |
#ifdef PEGASUS_OS_ZOS | #ifdef PEGASUS_OS_ZOS |
logIdendity = System::CIMSERVER.getCString(); |
logIdentity = strdup(System::CIMSERVER.getCString()); |
// If System Log is used open it | // If System Log is used open it |
System::openlog(logIdendity, LOG_PID, LOG_DAEMON); |
System::openlog(logIdentity, LOG_PID, LOG_DAEMON); |
#endif | #endif |
| |
#endif | #endif |
|
|
| |
#ifdef PEGASUS_OS_ZOS | #ifdef PEGASUS_OS_ZOS |
System::closelog(); | System::closelog(); |
|
free(logIdentity); |
#endif | #endif |
| |
#endif | #endif |
|
|
private: | private: |
| |
#ifdef PEGASUS_OS_ZOS | #ifdef PEGASUS_OS_ZOS |
CString logIdendity; |
char* logIdentity; |
#endif | #endif |
ofstream _logs[int(Logger::NUM_LOGS)]; | ofstream _logs[int(Logger::NUM_LOGS)]; |
}; | }; |
|
|
void Logger::_putInternal( | void Logger::_putInternal( |
LogFileType logFileType, | LogFileType logFileType, |
const String& systemId, | const String& systemId, |
const Uint32 logComponent, // TODO: Support logComponent mask in future release |
const Uint32 logComponent, // FUTURE: Support logComponent mask |
Uint32 logLevel, | Uint32 logLevel, |
const String& formatString, | const String& formatString, |
const String& messageId, // l10n |
const String& messageId, |
const Formatter::Arg& arg0, | const Formatter::Arg& arg0, |
const Formatter::Arg& arg1, | const Formatter::Arg& arg1, |
const Formatter::Arg& arg2, | const Formatter::Arg& arg2, |