forked from dashpay/dash
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge #1455: [Init] Add
-debuglogfile
option
882ef90 [Doc] Update release notes for `-debuglogfile` (random-zebra) 3d5ad7f test: Add tests for `-debuglogfile` with subdirs (random-zebra) 2c2e36d test: Add test for `-debuglogfile` (random-zebra) b44a324 Add `-debuglogfile` option (random-zebra) Pull request description: Implemented on top of - [x] #1449 - [x] #1437 - [x] #1439 - [x] #1450 - [x] #1451 Only last 4 commits are relevant to this PR. Backports bitcoin#11781 > This patch adds an option to configure the name and/or directory of the debug log file.</br></br> The user can specify either a relative path, in which case the path is relative to the (network specific) data directory. They can also specify an absolute path to put the log anywhere else in the file system. Functional test included. ACKs for top commit: Fuzzbawls: ACK 882ef90 furszy: utACK 882ef90 Tree-SHA512: 02a0e6487683e5111765af7296ef7ce035372febf037268d99d29b4c4a2f74bcc40f46a0f5b1bacddc2249c2a7e40255555e83ca9d51bf71d9e054c6e85765cc
- Loading branch information
Showing
6 changed files
with
105 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#!/usr/bin/env python3 | ||
# Copyright (c) 2017 The Bitcoin Core developers | ||
# Copyright (c) 20200 The PIVX Core developers | ||
# Distributed under the MIT software license, see the accompanying | ||
# file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
"""Test debug logging.""" | ||
|
||
import os | ||
|
||
from test_framework.test_framework import PivxTestFramework | ||
|
||
class LoggingTest(PivxTestFramework): | ||
def set_test_params(self): | ||
self.num_nodes = 1 | ||
self.setup_clean_chain = True | ||
|
||
def run_test(self): | ||
# test default log file name | ||
assert os.path.isfile(os.path.join(self.nodes[0].datadir, "regtest", "debug.log")) | ||
self.log.info("Default filename ok") | ||
|
||
# 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")) | ||
self.log.info("Alternative filename ok") | ||
|
||
# test alternative log file name outside datadir | ||
tempname = os.path.join(self.options.tmpdir, "foo.log") | ||
self.restart_node(0, ["-debuglogfile=%s" % tempname]) | ||
assert os.path.isfile(tempname) | ||
self.log.info("Alternative filename outside datadir ok") | ||
|
||
# check that invalid log (relative) will cause error | ||
invdir = os.path.join(self.nodes[0].datadir, "regtest", "foo") | ||
invalidname = os.path.join("foo", "foo.log") | ||
self.stop_node(0) | ||
self.assert_start_raises_init_error(0, ["-debuglogfile=%s" % (invalidname)], | ||
"Error: Could not open debug log file") | ||
assert not os.path.isfile(os.path.join(invdir, "foo.log")) | ||
self.log.info("Invalid relative filename throws") | ||
|
||
# check that a previously invalid log (relative) works after path exists | ||
os.mkdir(invdir) | ||
self.start_node(0, ["-debuglogfile=%s" % (invalidname)]) | ||
assert os.path.isfile(os.path.join(invdir, "foo.log")) | ||
self.log.info("Relative filename ok when path exists") | ||
|
||
# check that invalid log (absolute) will cause error | ||
self.stop_node(0) | ||
invdir = os.path.join(self.options.tmpdir, "foo") | ||
invalidname = os.path.join(invdir, "foo.log") | ||
self.assert_start_raises_init_error(0, ["-debuglogfile=%s" % invalidname], | ||
"Error: Could not open debug log file") | ||
assert not os.path.isfile(os.path.join(invdir, "foo.log")) | ||
self.log.info("Invalid absolute filename throws") | ||
|
||
# check that a previously invalid log (relative) works after path exists | ||
os.mkdir(invdir) | ||
self.start_node(0, ["-debuglogfile=%s" % (invalidname)]) | ||
assert os.path.isfile(os.path.join(invdir, "foo.log")) | ||
self.log.info("Absolute filename ok when path exists") | ||
|
||
|
||
if __name__ == '__main__': | ||
LoggingTest().main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters