version 1.40, 2008/12/16 18:56:00
|
version 1.41, 2008/12/19 10:17:10
|
|
|
#include <Pegasus/Common/FileSystem.h> | #include <Pegasus/Common/FileSystem.h> |
#include <Pegasus/Common/Tracer.h> | #include <Pegasus/Common/Tracer.h> |
#include <Pegasus/Common/TraceFileHandler.h> | #include <Pegasus/Common/TraceFileHandler.h> |
|
#include <Pegasus/Common/Logger.h> |
| |
#if defined(PEGASUS_OS_TYPE_WINDOWS) | #if defined(PEGASUS_OS_TYPE_WINDOWS) |
# include <Pegasus/Common/TraceFileHandlerWindows.cpp> | # include <Pegasus/Common/TraceFileHandlerWindows.cpp> |
|
|
{ | { |
_fileName = 0; | _fileName = 0; |
_fileHandle = 0; | _fileHandle = 0; |
_wroteToLog = false; |
_logErrorBitField = 0; |
_configHasChanged = true; | _configHasChanged = true; |
#ifdef PEGASUS_PLATFORM_LINUX_GENERIC_GNU | #ifdef PEGASUS_PLATFORM_LINUX_GENERIC_GNU |
_baseFileName = 0; | _baseFileName = 0; |
|
|
if (!fileHandle) | if (!fileHandle) |
{ | { |
// Unable to open file, log a message | // Unable to open file, log a message |
Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::WARNING, |
MessageLoaderParms parm( |
MessageLoaderParms( |
|
"Common.TraceFileHandler.FAILED_TO_OPEN_FILE_SYSMSG", | "Common.TraceFileHandler.FAILED_TO_OPEN_FILE_SYSMSG", |
"Failed to open file $0: $1", | "Failed to open file $0: $1", |
fileName,PEGASUS_SYSTEM_ERRORMSG_NLS)); |
fileName,PEGASUS_SYSTEM_ERRORMSG_NLS); |
|
_logError(TRCFH_FAILED_TO_OPEN_FILE_SYSMSG,parm); |
return 0; | return 0; |
} | } |
| |
|
|
// | // |
if (!System::verifyFileOwnership(fileName)) | if (!System::verifyFileOwnership(fileName)) |
{ | { |
Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::WARNING, |
MessageLoaderParms parm( |
MessageLoaderParms( |
|
"Common.TraceFileHandler.UNEXPECTED_FILE_OWNER", | "Common.TraceFileHandler.UNEXPECTED_FILE_OWNER", |
"File $0 is not owned by user $1.", fileName, |
"File $0 is not owned by user $1.", |
System::getEffectiveUserName())); |
fileName, |
|
System::getEffectiveUserName()); |
|
_logError(TRCFH_UNEXPECTED_FILE_OWNER,parm); |
fclose(fileHandle); | fclose(fileHandle); |
return 0; | return 0; |
} | } |
|
|
String(fileName), (_S_IREAD|_S_IWRITE)) ) | String(fileName), (_S_IREAD|_S_IWRITE)) ) |
#endif | #endif |
{ | { |
Logger::put_l( |
MessageLoaderParms parm( |
Logger::ERROR_LOG, |
|
System::CIMSERVER, |
|
Logger::WARNING, |
|
MessageLoaderParms( |
|
"Common.TraceFileHandler.FAILED_TO_SET_FILE_PERMISSIONS", | "Common.TraceFileHandler.FAILED_TO_SET_FILE_PERMISSIONS", |
"Failed to set permissions on file $0", | "Failed to set permissions on file $0", |
fileName)); |
fileName); |
|
_logError(TRCFH_FAILED_TO_SET_FILE_PERMISSIONS,parm); |
fclose(fileHandle); | fclose(fileHandle); |
return 0; | return 0; |
} | } |
|
|
return fileHandle; | return fileHandle; |
} | } |
| |
|
void TraceFileHandler::_logError( |
|
ErrLogMessageIds msgID, |
|
const MessageLoaderParms & parms) |
|
{ |
|
// msgID has to be within range, else we have a severe coding error |
|
PEGASUS_ASSERT((msgID >= TRCFH_FAILED_TO_OPEN_FILE_SYSMSG) && |
|
(msgID <= TRCFH_INVALID_FILE_HANDLE)); |
|
|
|
if (_logErrorBitField & (1 << msgID) == 0) |
|
{ |
|
// log message not yet written, write log message |
|
Logger::put_l( |
|
Logger::ERROR_LOG, |
|
System::CIMSERVER, |
|
Logger::WARNING, |
|
parms); |
|
// mark bit in log error field to flag that specific log message |
|
// has been written |
|
_logErrorBitField |= (1 << msgID); |
|
} |
|
} |
|
|
|
|
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |