diff options
| author | bitflash-maintainer <noreply@bitflash.invalid> | 2026-09-02 05:26:51 +0000 |
|---|---|---|
| committer | bitflash-maintainer <noreply@bitflash.invalid> | 2026-09-02 05:26:51 +0000 |
| commit | ae1c6a7b49d9b4f8cf7218c0baec84f348eb5ef6 (patch) | |
| tree | c8444d683f25d54135d5026eca4c677f24b7ab41 /src/util.cpp | |
| parent | e4f898c4a6b9900553c64b9804889b5fdae3e55f (diff) | |
log: cap debug.log in-process, and ship a logrotate policy
debug.log grew without bound (production: 1.95 GiB, 51-129 MB/day).
Nothing shrank it once the process was up -- there is no
ShrinkDebugFile in this tree, and upstream's only ran at startup.
OutputDebugStringF now rolls the file to debug.log.old when it
passes -maxdebugfilesize (MB, default 1024, 0 disables). The write
path already opens and closes the file per line under one lock, so
the rename-and-reopen is a few lines inside that lock and no fd can
be stranded mid-roll.
contrib/logrotate/bitflash-debug.logrotate is the longer-term policy
(size 1G, rotate 4, compress, missingok, notifempty, copytruncate);
copytruncate keeps the writer's append handle valid across rotation.
Closes #34
Diffstat (limited to 'src/util.cpp')
| -rw-r--r-- | src/util.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/util.cpp b/src/util.cpp index 0cd0133..52cda84 100644 --- a/src/util.cpp +++ b/src/util.cpp | |||
| @@ -8,6 +8,11 @@ | |||
| 8 | 8 | ||
| 9 | bool fDebug = false; | 9 | bool fDebug = false; |
| 10 | 10 | ||
| 11 | // In-process cap for debug.log, in bytes. Default matches the 1G trigger of | ||
| 12 | // the shipped logrotate policy so a long-running node stays bounded even | ||
| 13 | // without it; -maxdebugfilesize=N (MB) tunes it, 0 disables. | ||
| 14 | int64 nMaxDebugFileSize = 1024 * 1024 * (int64)1024; | ||
| 15 | |||
| 11 | // --------------------------------------------------------------------------- | 16 | // --------------------------------------------------------------------------- |
| 12 | // Categorized, burst-collapsing logging -- see the LogPrint doc comment in | 17 | // Categorized, burst-collapsing logging -- see the LogPrint doc comment in |
| 13 | // util.h for the problem this solves. | 18 | // util.h for the problem this solves. |