version 1.7, 2006/11/10 18:14:58
|
version 1.8, 2007/03/16 17:16:50
|
|
|
| |
#if defined(PEGASUS_OS_VMS) | #if defined(PEGASUS_OS_VMS) |
| |
void TraceFileHandler::handleMessage( |
void TraceFileHandler::prepareFileHandle(void) |
const char *message, |
|
const char *fmt, va_list argList) |
|
{ | { |
Sint32 retCode; | Sint32 retCode; |
Sint32 fileDesc; |
|
|
|
// Do not add Trace calls in the Critical section |
|
// ---- BEGIN CRITICAL SECTION |
|
|
|
// Check if the file has been deleted, if so re-open the file and | // Check if the file has been deleted, if so re-open the file and |
// continue | // continue |
if (!System::exists(_fileName)) | if (!System::exists(_fileName)) |
|
|
return; | return; |
} | } |
} | } |
|
|
// Seek to the end of File | // Seek to the end of File |
|
|
retCode = fseek(_fileHandle, 0, SEEK_END); | retCode = fseek(_fileHandle, 0, SEEK_END); |
|
} |
|
|
|
void TraceFileHandler::handleMessage( |
|
const char *message, |
|
const char *fmt, va_list argList) |
|
{ |
|
Sint32 retCode; |
|
Sint32 fileDesc; |
|
|
|
// Do not add Trace calls in the Critical section |
|
// ---- BEGIN CRITICAL SECTION |
|
|
|
prepareFileHandle(); |
| |
// Write the message to the file | // Write the message to the file |
| |
|
|
return; | return; |
} | } |
| |
#else /* PEGASUS_OS_VMS */ |
void TraceFileHandler::handleMessage(const char *message) |
|
|
void TraceFileHandler::handleMessage( |
|
const char *message, |
|
const char *fmt, va_list argList) |
|
{ |
|
if (!_fileHandle) |
|
{ | { |
// The trace file is not open, which means an earlier fopen() was |
Sint32 retCode; |
// unsuccessful. Stop now to avoid logging duplicate error messages. |
Sint32 fileDesc; |
return; |
|
} |
|
| |
// Do not add Trace calls in the Critical section | // Do not add Trace calls in the Critical section |
// ---- BEGIN CRITICAL SECTION | // ---- BEGIN CRITICAL SECTION |
AutoMutex writeLock(writeMutex); |
|
| |
|
prepareFileHandle(); |
|
|
|
// Write the message to the file |
|
|
|
retCode = fprintf(_fileHandle, "%s\n", message); |
|
retCode = fflush(_fileHandle); |
|
fileDesc = fileno(_fileHandle); |
|
retCode = fsync(fileDesc); |
|
_wroteToLog = false; |
|
// retCode = fclose(_fileHandle); |
|
// _fileHandle = 0; |
|
|
|
// ---- END CRITICAL SECTION |
|
|
|
return; |
|
} |
|
|
|
|
|
#else /* PEGASUS_OS_VMS */ |
|
|
|
void TraceFileHandler::prepareFileHandle(void) |
|
{ |
// If the file has been deleted, re-open it and continue | // If the file has been deleted, re-open it and continue |
if (!System::exists(_fileName)) | if (!System::exists(_fileName)) |
{ | { |
|
|
} | } |
} | } |
# endif | # endif |
|
} |
| |
|
void TraceFileHandler::handleMessage( |
|
const char *message, |
|
const char *fmt, va_list argList) |
|
{ |
|
if (!_fileHandle) |
|
{ |
|
// The trace file is not open, which means an earlier fopen() was |
|
// unsuccessful. Stop now to avoid logging duplicate error messages. |
|
return; |
|
} |
|
|
|
// Do not add Trace calls in the Critical section |
|
// ---- BEGIN CRITICAL SECTION |
|
AutoMutex writeLock(writeMutex); |
|
|
|
prepareFileHandle(); |
// Write the message to the file | // Write the message to the file |
fprintf(_fileHandle, "%s", message); | fprintf(_fileHandle, "%s", message); |
vfprintf(_fileHandle, fmt, argList); | vfprintf(_fileHandle, fmt, argList); |
fprintf(_fileHandle, "\n"); | fprintf(_fileHandle, "\n"); |
fflush(_fileHandle); | fflush(_fileHandle); |
|
// ---- END CRITICAL SECTION |
|
} |
|
|
|
void TraceFileHandler::handleMessage(const char *message) |
|
{ |
|
if (!_fileHandle) |
|
{ |
|
// The trace file is not open, which means an earlier fopen() was |
|
// unsuccessful. Stop now to avoid logging duplicate error messages. |
|
return; |
|
} |
|
|
|
// Do not add Trace calls in the Critical section |
|
// ---- BEGIN CRITICAL SECTION |
|
AutoMutex writeLock(writeMutex); |
|
|
|
prepareFileHandle(); |
|
// Write the message to the file |
|
fprintf(_fileHandle, "%s\n", message); |
|
fflush(_fileHandle); |
|
// ---- END CRITICAL SECTION |
} | } |
| |
|
|
#endif /* !PEGASUS_OS_VMS */ | #endif /* !PEGASUS_OS_VMS */ |
| |
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |