version 1.22, 2008/12/19 10:17:10
|
version 1.27, 2013/05/03 04:49:10
|
|
|
| |
static Mutex writeMutex; | static Mutex writeMutex; |
| |
//////////////////////////////////////////////////////////////////////////////// |
|
// On other platforms prepares the file handle (open file etc.). |
|
// Implementation of this function is platform specific |
|
// |
|
// Note: The current implementation on Windows does nothing. |
|
// Should be optimized out by the compiler |
|
//////////////////////////////////////////////////////////////////////////////// |
|
void TraceFileHandler::prepareFileHandle(void) |
|
{ |
|
return; |
|
} |
|
| |
//////////////////////////////////////////////////////////////////////////////// | //////////////////////////////////////////////////////////////////////////////// |
// Writes message to file. | // Writes message to file. |
|
|
//////////////////////////////////////////////////////////////////////////////// | //////////////////////////////////////////////////////////////////////////////// |
void TraceFileHandler::handleMessage( | void TraceFileHandler::handleMessage( |
const char* message, | const char* message, |
Uint32 msgLen, |
Uint32, |
const char* fmt, | const char* fmt, |
va_list argList) | va_list argList) |
{ | { |
Uint32 retCode; | Uint32 retCode; |
| |
|
|
if (_configHasChanged) | if (_configHasChanged) |
{ | { |
_reConfigure(); | _reConfigure(); |
} | } |
| |
if (_fileHandle) |
if (!_fileHandle) |
{ | { |
|
// The trace file is not open, which means an earlier fopen() was |
|
// unsuccessful. Stop now to avoid logging duplicate error messages. |
|
return; |
|
} |
|
|
AutoMutex writeLock(writeMutex); | AutoMutex writeLock(writeMutex); |
| |
|
if(!_fileExists(_fileName)) |
|
{ |
|
return; |
|
} |
|
|
//Move to the End of File | //Move to the End of File |
fseek(_fileHandle,0,SEEK_SET); | fseek(_fileHandle,0,SEEK_SET); |
| |
|
|
// thus allow writing of errors to log again | // thus allow writing of errors to log again |
_logErrorBitField = 0; | _logErrorBitField = 0; |
} | } |
} |
|
else |
|
{ |
|
// Invalid file handle |
|
// Log message |
|
MessageLoaderParms parm( |
|
"Common.TraceFileHandlerWindows.INVALID_FILE_HANDLE", |
|
"Invalid file handle for file $0", |
|
_fileName); |
|
_logError(TRCFH_INVALID_FILE_HANDLE,parm); |
|
} |
|
} | } |
| |
//////////////////////////////////////////////////////////////////////////////// | //////////////////////////////////////////////////////////////////////////////// |
|
|
// Will have to be enhanced to support synchronous write operations to | // Will have to be enhanced to support synchronous write operations to |
// the same file. | // the same file. |
//////////////////////////////////////////////////////////////////////////////// | //////////////////////////////////////////////////////////////////////////////// |
void TraceFileHandler::handleMessage(const char* message, Uint32 msgLen) |
void TraceFileHandler::handleMessage(const char* message, Uint32) |
{ | { |
Uint32 retCode; | Uint32 retCode; |
| |
|
|
_reConfigure(); | _reConfigure(); |
} | } |
| |
if (_fileHandle) |
if (!_fileHandle) |
{ | { |
|
// The trace file is not open, which means an earlier fopen() was |
|
// unsuccessful. Stop now to avoid logging duplicate error messages. |
|
return; |
|
} |
|
|
AutoMutex writeLock(writeMutex); | AutoMutex writeLock(writeMutex); |
| |
|
if(!_fileExists(_fileName)) |
|
{ |
|
return; |
|
} |
|
|
//Move to the End of File | //Move to the End of File |
fseek(_fileHandle,0,SEEK_SET); | fseek(_fileHandle,0,SEEK_SET); |
| |
|
|
// thus allow writing of errors to log again | // thus allow writing of errors to log again |
_logErrorBitField = 0; | _logErrorBitField = 0; |
} | } |
} |
|
else |
|
{ |
|
// Invalid file handle |
|
// Log message |
|
MessageLoaderParms parm( |
|
"Common.TraceFileHandlerWindows.INVALID_FILE_HANDLE", |
|
"Invalid file handle for file $0", |
|
_fileName); |
|
_logError(TRCFH_INVALID_FILE_HANDLE,parm); |
|
} |
|
} | } |
| |
| |