MCPcopy Create free account
hub / github.com/ElementsProject/elements / main

Function main

test/bitcoin_functional/functional/combine_logs.py:29–56  ·  view source on GitHub ↗

Main function. Parses args, reads the log files and renders them as text or html.

()

Source from the content-addressed store, hash-verified

27LogEvent = namedtuple('LogEvent', ['timestamp', 'source', 'event'])
28
29def main():
30 """Main function. Parses args, reads the log files and renders them as text or html."""
31 parser = argparse.ArgumentParser(
32 description=__doc__, formatter_class=argparse.RawTextHelpFormatter)
33 parser.add_argument(
34 'testdir', nargs='?', default='',
35 help=('temporary test directory to combine logs from. '
36 'Defaults to the most recent'))
37 parser.add_argument('-c', '--color', dest='color', action='store_true', help='outputs the combined log with events colored by source (requires posix terminal colors. Use less -r for viewing)')
38 parser.add_argument('--html', dest='html', action='store_true', help='outputs the combined log as html. Requires jinja2. pip install jinja2')
39 args = parser.parse_args()
40
41 if args.html and args.color:
42 print("Only one out of --color or --html should be specified")
43 sys.exit(1)
44
45 testdir = args.testdir or find_latest_test_dir()
46
47 if not testdir:
48 print("No test directories found")
49 sys.exit(1)
50
51 if not args.testdir:
52 print("Opening latest test directory: {}".format(testdir), file=sys.stderr)
53
54 log_events = read_logs(testdir)
55
56 print_logs(log_events, color=args.color, html=args.html)
57
58def read_logs(tmp_dir):
59 """Reads log files.

Callers 1

combine_logs.pyFile · 0.70

Calls 5

print_logsFunction · 0.85
parse_argsMethod · 0.80
formatMethod · 0.80
find_latest_test_dirFunction · 0.70
read_logsFunction · 0.70

Tested by

no test coverage detected