version 1.16, 2008/12/16 18:56:00
|
version 1.17, 2008/12/19 10:17:10
|
|
|
#if defined(PEGASUS_OS_VMS) | #if defined(PEGASUS_OS_VMS) |
# include <fcntl.h> | # include <fcntl.h> |
#endif | #endif |
#include <Pegasus/Common/Logger.h> |
|
#include <Pegasus/Common/System.h> | #include <Pegasus/Common/System.h> |
#include <Pegasus/Common/TraceFileHandler.h> | #include <Pegasus/Common/TraceFileHandler.h> |
#include <Pegasus/Common/Mutex.h> | #include <Pegasus/Common/Mutex.h> |
|
|
if (!_fileHandle) | if (!_fileHandle) |
{ | { |
// Unable to re-open file, log a message | // Unable to re-open file, log a message |
|
MessageLoaderParms parm( |
Logger::put_l( |
|
Logger::ERROR_LOG, System::CIMSERVER, Logger::WARNING, |
|
MessageLoaderParms( |
|
"Common.TraceFileHandlerUnix.FAILED_TO_OPEN_FILE", | "Common.TraceFileHandlerUnix.FAILED_TO_OPEN_FILE", |
"Failed to open File $0", | "Failed to open File $0", |
_fileName)); |
_fileName); |
|
_logError(TRCFH_FAILED_TO_OPEN_FILE_SYSMSG,parm); |
return; | return; |
} | } |
| |
|
|
if (!FileSystem::changeFilePermissions( | if (!FileSystem::changeFilePermissions( |
String(_fileName), (S_IRUSR | S_IWUSR))) | String(_fileName), (S_IRUSR | S_IWUSR))) |
{ | { |
Logger::put_l( |
MessageLoaderParms parm( |
Logger::ERROR_LOG, System::CIMSERVER, Logger::WARNING, |
"Common.TraceFileHandlerUnix.FAILED_TO_SET_FILE_PERMISSIONS", |
MessageLoaderParms( |
|
"Common.TraceFileHandlerUnix." |
|
"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); |
return; | return; |
} | } |
} | } |
|
|
retCode = fflush(_fileHandle); | retCode = fflush(_fileHandle); |
fileDesc = fileno(_fileHandle); | fileDesc = fileno(_fileHandle); |
retCode = fsync(fileDesc); | retCode = fsync(fileDesc); |
_wroteToLog = false; |
if (retCode == 0) |
// retCode = fclose(_fileHandle); |
{ |
// _fileHandle = 0; |
// trace message successful written, reset error log messages |
|
// thus allow writing of errors to log again |
|
_logErrorBitField = 0; |
|
} |
| |
// ---- END CRITICAL SECTION | // ---- END CRITICAL SECTION |
| |
|
|
retCode = fflush(_fileHandle); | retCode = fflush(_fileHandle); |
fileDesc = fileno(_fileHandle); | fileDesc = fileno(_fileHandle); |
retCode = fsync(fileDesc); | retCode = fsync(fileDesc); |
_wroteToLog = false; |
if (retCode == 0) |
// retCode = fclose(_fileHandle); |
{ |
// _fileHandle = 0; |
// trace message successful written, reset error log messages |
|
// thus allow writing of errors to log again |
|
_logErrorBitField = 0; |
|
} |
| |
// ---- END CRITICAL SECTION | // ---- END CRITICAL SECTION |
| |
|
|
if (!_fileHandle) | if (!_fileHandle) |
{ | { |
// Unable to open file, log a message | // Unable to open file, log a message |
if (!_wroteToLog) |
MessageLoaderParms parm( |
{ |
|
Logger::put_l( |
|
Logger::ERROR_LOG, System::CIMSERVER, Logger::WARNING, |
|
MessageLoaderParms( |
|
"Common.TraceFileHandler.FAILED_TO_OPEN_FILE", | "Common.TraceFileHandler.FAILED_TO_OPEN_FILE", |
"Failed to open File $0", | "Failed to open File $0", |
_fileName)); |
_fileName); |
_wroteToLog = true; |
_logError(TRCFH_FAILED_TO_OPEN_FILE_SYSMSG,parm); |
} |
|
return; | return; |
} | } |
} | } |
|
|
fprintf(_fileHandle, "%s", message); | fprintf(_fileHandle, "%s", message); |
vfprintf(_fileHandle, fmt, argList); | vfprintf(_fileHandle, fmt, argList); |
fprintf(_fileHandle, "\n"); | fprintf(_fileHandle, "\n"); |
fflush(_fileHandle); |
if (0 == fflush(_fileHandle)) |
|
{ |
|
// trace message successful written, reset error log messages |
|
// thus allow writing of errors to log again |
|
_logErrorBitField = 0; |
|
} |
|
|
// ---- END CRITICAL SECTION | // ---- END CRITICAL SECTION |
} | } |
| |
|
|
prepareFileHandle(); | prepareFileHandle(); |
// Write the message to the file | // Write the message to the file |
fprintf(_fileHandle, "%s\n", message); | fprintf(_fileHandle, "%s\n", message); |
fflush(_fileHandle); |
if (0 == fflush(_fileHandle)) |
|
{ |
|
// trace message successful written, reset error log messages |
|
// thus allow writing of errors to log again |
|
_logErrorBitField = 0; |
|
} |
// ---- END CRITICAL SECTION | // ---- END CRITICAL SECTION |
} | } |
| |