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:
1 parent
79e30bbda4
commit
672e06a951
1 file changed
+2
-1
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user