Shared/Logs: Add workaround for "w" flag used with dynamic name files

Ignore "w" flag and always use "a" for log files with dynamic name since the file handle is created at every log line and "w" would delete any other logged line from previous _write() calls.
The best solution would be to overwrite only at first call and append at any other call.
This commit is contained in:
jackpoz
2014-02-07 22:23:24 +01:00
parent 79e30bbda4
commit 672e06a951

View File

@@ -49,7 +49,8 @@ void AppenderFile::_write(LogMessage const& message)
{
char namebuf[TRINITY_PATH_MAX];
snprintf(namebuf, TRINITY_PATH_MAX, filename.c_str(), message.param1.c_str());
logfile = OpenFile(namebuf, mode, backup || exceedMaxSize);
// always use "a" with dynamic name otherwise it could delete the log we wrote in last _write() call
logfile = OpenFile(namebuf, "a", backup || exceedMaxSize);
}
else if (exceedMaxSize)
logfile = OpenFile(filename, "w", true);