Page MenuHomePhabricator

[Linter] Check the log prints are terminated with a newline
ClosedPublic

Authored by Fabien on Sep 5 2019, 13:21.

Details

Summary

This will detect the log prints missing a newline, avoiding the logs to
become unreadable.
Under some circumstances there is a need for a non newline terminated
log. In this case the aliases macros LogPrintToBeContinued() and
LogPrintfToBeContinued() can be used instead to make the intent
explicit. Core uses an inline comment (/* Continuated */) for the same
purpose which would cause issues with clang-format if the line ends up
being too long.

Backport of core PR12891 and PR13153
https://github.com/bitcoin/bitcoin/pull/12891/files
https://github.com/bitcoin/bitcoin/pull/13153/files

Note that one of the fix in net_processing.cpp doesn't exist in Core
due to PR12218. However this PR is not appropriated for our codebase.

Test Plan

Should return no error:

arc lint --everything

Edit any file to remove the \n at the end of a LogPrint() or
LogPrintf() message and check the linter catches it.

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

Fabien created this revision.Sep 5 2019, 13:21
Herald added a reviewer: Restricted Project. · View Herald TranscriptSep 5 2019, 13:21
deadalnix accepted this revision.Sep 8 2019, 14:03
This revision is now accepted and ready to land.Sep 8 2019, 14:03
Fabien edited the summary of this revision. (Show Details)Sep 9 2019, 06:10
Fabien updated this revision to Diff 11156.Sep 9 2019, 06:16

Rebase.