test/functional/combine_logs.py
def main():
    """Main function. Parses args, reads the log files and renders them as text or html."""
    parser = argparse.ArgumentParser(
        description=__doc__, formatter_class=argparse.RawTextHelpFormatter)
    parser.add_argument(
        'testdir', nargs='?', default='',
        help=('temporary test directory to combine logs from. '
              'Defaults to the most recent'))
    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)')
    parser.add_argument('--html', dest='html', action='store_true', help='outputs the combined log as html. Requires jinja2. pip install jinja2')
    args = parser.parse_args()

    if args.html and args.color:
        print("Only one out of --color or --html should be specified")
        sys.exit(1)

    testdir = args.testdir or find_latest_test_dir()

    if not testdir:
        print("No test directories found")
        sys.exit(1)

    if not args.testdir:
        print("Opening latest test directory: {}".format(testdir), file=sys.stderr)

    colors = defaultdict(lambda: '')
    if args.color:
        colors["test"] = "\033[0;36m"  # CYAN
        colors["node0"] = "\033[0;34m"  # BLUE
        colors["node1"] = "\033[0;32m"  # GREEN
        colors["node2"] = "\033[0;31m"  # RED
        colors["node3"] = "\033[0;33m"  # YELLOW
        colors["reset"] = "\033[0m"  # Reset font color

    log_events = read_logs(testdir)

    if args.html:
        print_logs_html(log_events)
    else:
        print_logs_plain(log_events, colors)
        print_node_warnings(testdir, colors)
Main function. Parses args, reads the log files and renders them as text or html.
Main function. Parses args, reads the log files and renders them as text or html.
Main function . Parses args reads the log files and renders them as text or html .
def main():
    parser = argparse.ArgumentParser(
        description=__doc__, formatter_class=argparse.RawTextHelpFormatter)
    parser.add_argument(
        'testdir', nargs='?', default='',
        help=('temporary test directory to combine logs from. '
              'Defaults to the most recent'))
    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)')
    parser.add_argument('--html', dest='html', action='store_true', help='outputs the combined log as html. Requires jinja2. pip install jinja2')
    args = parser.parse_args()
    if args.html and args.color:
        print("Only one out of --color or --html should be specified")
        sys.exit(1)
    testdir = args.testdir or find_latest_test_dir()
    if not testdir:
        print("No test directories found")
        sys.exit(1)
    if not args.testdir:
        print("Opening latest test directory: {}".format(testdir), file=sys.stderr)
    colors = defaultdict(lambda: '')
    if args.color:
        colors["test"] = "\033[0;36m"  
        colors["node0"] = "\033[0;34m"  
        colors["node1"] = "\033[0;32m"  
        colors["node2"] = "\033[0;31m"  
        colors["node3"] = "\033[0;33m"  
        colors["reset"] = "\033[0m"  
    log_events = read_logs(testdir)
    if args.html:
        print_logs_html(log_events)
    else:
        print_logs_plain(log_events, colors)
        print_node_warnings(testdir, colors)
def main ( ) : parser = argparse . ArgumentParser ( description = __doc__ , formatter_class = argparse . RawTextHelpFormatter ) parser . add_argument ( 'testdir' , nargs = '?' , default = '' , help = ( 'temporary test directory to combine logs from. ' 'Defaults to the most recent' ) ) 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)' ) parser . add_argument ( '--html' , dest = 'html' , action = 'store_true' , help = 'outputs the combined log as html. Requires jinja2. pip install jinja2' ) args = parser . parse_args ( ) if args . html and args . color : print ( "Only one out of --color or --html should be specified" ) sys . exit ( 1 ) testdir = args . testdir or find_latest_test_dir ( ) if not testdir : print ( "No test directories found" ) sys . exit ( 1 ) if not args . testdir : print ( "Opening latest test directory: {}" . format ( testdir ) , file = sys . stderr ) colors = defaultdict ( lambda : '' ) if args . color : colors [ "test" ] = "\033[0;36m" colors [ "node0" ] = "\033[0;34m" colors [ "node1" ] = "\033[0;32m" colors [ "node2" ] = "\033[0;31m" colors [ "node3" ] = "\033[0;33m" colors [ "reset" ] = "\033[0m" log_events = read_logs ( testdir ) if args . html : print_logs_html ( log_events ) else : print_logs_plain ( log_events , colors ) print_node_warnings ( testdir , colors )
Main function.
Main function .
"""Main function. Parses args, reads the log files and renders them as text or html.""" # CYAN # BLUE # GREEN # RED # YELLOW # Reset font color