mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-05-04 10:59:08 +02:00
Print to console by default when not run with -daemon
Printing to the debug log file can be disabled with -nodebulogfile
This commit is contained in:
committed by
practicalswift
parent
07825088f9
commit
6a3b0d3d1a
@@ -15,13 +15,17 @@ class LoggingTest(BitcoinTestFramework):
|
||||
self.num_nodes = 1
|
||||
self.setup_clean_chain = True
|
||||
|
||||
def relative_log_path(self, name):
|
||||
return os.path.join(self.nodes[0].datadir, "regtest", name)
|
||||
|
||||
def run_test(self):
|
||||
# test default log file name
|
||||
assert os.path.isfile(os.path.join(self.nodes[0].datadir, "regtest", "debug.log"))
|
||||
default_log_path = self.relative_log_path("debug.log")
|
||||
assert os.path.isfile(default_log_path)
|
||||
|
||||
# test alternative log file name in datadir
|
||||
self.restart_node(0, ["-debuglogfile=foo.log"])
|
||||
assert os.path.isfile(os.path.join(self.nodes[0].datadir, "regtest", "foo.log"))
|
||||
assert os.path.isfile(self.relative_log_path("foo.log"))
|
||||
|
||||
# test alternative log file name outside datadir
|
||||
tempname = os.path.join(self.options.tmpdir, "foo.log")
|
||||
@@ -29,7 +33,7 @@ class LoggingTest(BitcoinTestFramework):
|
||||
assert os.path.isfile(tempname)
|
||||
|
||||
# check that invalid log (relative) will cause error
|
||||
invdir = os.path.join(self.nodes[0].datadir, "regtest", "foo")
|
||||
invdir = self.relative_log_path("foo")
|
||||
invalidname = os.path.join("foo", "foo.log")
|
||||
self.stop_node(0)
|
||||
exp_stderr = "Error: Could not open debug log file \S+$"
|
||||
@@ -55,6 +59,17 @@ class LoggingTest(BitcoinTestFramework):
|
||||
self.start_node(0, ["-debuglogfile=%s" % (invalidname)])
|
||||
assert os.path.isfile(os.path.join(invdir, "foo.log"))
|
||||
|
||||
# check that -nodebuglogfile disables logging
|
||||
self.stop_node(0)
|
||||
os.unlink(default_log_path)
|
||||
assert not os.path.isfile(default_log_path)
|
||||
self.start_node(0, ["-nodebuglogfile"])
|
||||
assert not os.path.isfile(default_log_path)
|
||||
|
||||
# just sanity check no crash here
|
||||
self.stop_node(0)
|
||||
self.start_node(0, ["-debuglogfile=%s" % os.devnull])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
LoggingTest().main()
|
||||
|
||||
@@ -78,7 +78,17 @@ class TestNode():
|
||||
# For those callers that need more flexibility, they can just set the args property directly.
|
||||
# Note that common args are set in the config file (see initialize_datadir)
|
||||
self.extra_args = extra_args
|
||||
self.args = [self.binary, "-datadir=" + self.datadir, "-logtimemicros", "-debug", "-debugexclude=libevent", "-debugexclude=leveldb", "-mocktime=" + str(mocktime), "-uacomment=testnode%d" % i]
|
||||
self.args = [
|
||||
self.binary,
|
||||
"-datadir=" + self.datadir,
|
||||
"-logtimemicros",
|
||||
"-debug",
|
||||
"-debugexclude=libevent",
|
||||
"-debugexclude=leveldb",
|
||||
"-mocktime=" + str(mocktime),
|
||||
"-uacomment=testnode%d" % i,
|
||||
"-noprinttoconsole"
|
||||
]
|
||||
|
||||
self.cli = TestNodeCLI(os.getenv("BITCOINCLI", "bitcoin-cli"), self.datadir)
|
||||
self.use_cli = use_cli
|
||||
|
||||
Reference in New Issue
Block a user