Page MenuHomePhabricator

logging: add LogError, LogWarning, LogInfo, LogDebug, LogTrace
ClosedPublic

Authored by PiRK on Jun 19 2025, 13:11.

Details

Summary

These provide simple and clear ways to write the most common logging
operations:

LogInfo("msg");
LogDebug(BCLog::LogFlags::NET, "msg");

LogError("msg");
LogWarning("msg");
LogTrace(BCLog::LogFlags::NET, "msg");

For cases where the level cannot be hardcoded, LogPrintLevel(category,
level, ...) remains available.

This is a partial backport of core#28318
https://github.com/bitcoin/bitcoin/pull/28318/commits/f7ce5ac08c669ac763e275bb7c82dcfb2b1b6c33
Depends on D18274

Test Plan
arc lint
ninja all check-all

in the next diff try removing some "\n" in the newly added LogInfo/LogWarning lines, see that the linter catches the issue.

Event Timeline

PiRK requested review of this revision.Jun 19 2025, 13:11
src/test/logging_tests.cpp
172

the need for this extra flush remains a mystery (first used in D17217)

add unit tests for format-strings linter

This revision is now accepted and ready to land.Jun 20 2025, 08:02