Cherry-picked ef6fa1c38e1bd115d1cce155907023d79da379d8 from the "up for grabs" PR: "Smarter default behavior for -printtoconsole" (#12689).
See previous review in #12689.
Cherry-picked ef6fa1c38e1bd115d1cce155907023d79da379d8 from the "up for grabs" PR: "Smarter default behavior for -printtoconsole" (#12689).
See previous review in #12689.
Printing to the debug log file can be disabled with -nodebulogfile
@ryanofsky Could you re-review here.
Previous utACK:ers @MeshCollider and @jnewbery might want to take a look at this one too? :-)
concept ACK
1232 | - // and because this needs to happen before any other debug.log printing 1233 | - ShrinkDebugFile(); 1234 | - } 1235 | - 1236 | if (fPrintToDebugLog) { 1237 | + if (gArgs.GetBoolArg("-shrinkdebugfile", logCategories == BCLog::NONE)) {
Whoa - good catch to move this inside the if (fPrintToDebugLog)
Thanks for reviving this, tested ACK 6a3b0d3d1aee1ab924f30b9910bc517c764917cd:
src/bitcoind -regtest works as expected, now prints logging outputsrc/bitcoind -regtest -noprinttoconsole successfully silences logging outputsrc/bitcoind -regtest -daemon successfully silences logging output14 | @@ -15,21 +15,25 @@ def set_test_params(self): 15 | self.num_nodes = 1 16 | self.setup_clean_chain = True 17 | 18 | + def relative_log_path(self, name): 19 | + return os.path.join(self.nodes[0].datadir, "regtest", name)
nit: IIRC datadir is absolute, so the relative in the method name is confusing.
58 | @@ -55,6 +59,17 @@ def run_test(self): 59 | self.start_node(0, ["-debuglogfile=%s" % (invalidname)]) 60 | assert os.path.isfile(os.path.join(invdir, "foo.log")) 61 | 62 | + # check that -nodebuglogfile disables logging 63 | + self.stop_node(0) 64 | + os.unlink(default_log_path)
Nit: Could use the identical and more clear "remove", since unlink seems to be some unix specific thing, but we also run the tests on windows.
utACK 6a3b0d3d1aee1ab924f30b9910bc517c764917cd. Some naming nits in tests.
825 | {
826 | - fPrintToConsole = gArgs.GetBoolArg("-printtoconsole", false);
827 | + // Add newlines to the logfile to distinguish this execution from the last
828 | + // one; called before console logging is set up, so this is only sent to
829 | + // debug.log.
830 | + LogPrintf("\n\n\n\n\n");
Hmm, won't it print these newlines even if fPrintToDebugLog ends up being false?