Skip to content

Commit

Permalink
Shrink debug log on SIGHUP as well as startup
Browse files Browse the repository at this point in the history
  • Loading branch information
chromatic committed Jun 23, 2024
1 parent 5bbb1fa commit c1d8d61
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ std::string HelpMessage(HelpMessageMode mode)
{
strUsage += HelpMessageOpt("-printpriority", strprintf("Log transaction priority and fee per kB when mining blocks (default: %u)", DEFAULT_PRINTPRIORITY));
}
strUsage += HelpMessageOpt("-shrinkdebugfile", _("Shrink debug.log file on client startup (default: 1 when no -debug)"));
strUsage += HelpMessageOpt("-shrinkdebugfile", _("Shrink debug.log file on startup/SIGHUP (default: 1 when no -debug)"));

AppendParamsHelpMessages(strUsage, showDebug);

Expand Down
4 changes: 4 additions & 0 deletions src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,10 @@ int LogPrintStr(const std::string &str)
// reopen the log file, if requested
if (fReopenDebugLog) {
fReopenDebugLog = false;

if (GetBoolArg("-shrinkdebugfile", !fDebug)) {
ShrinkDebugFile();
}
fs::path pathDebug = GetDataDir() / "debug.log";
if (fsbridge::freopen(pathDebug,"a",fileout) != NULL)
setbuf(fileout, NULL); // unbuffered
Expand Down

0 comments on commit c1d8d61

Please sign in to comment.