1#!/usr/bin/env python3
2#
3# Copyright (c) 2024 Nordic Semiconductor ASA
4#
5# SPDX-License-Identifier: Apache-2.0
6
7"""
8Log Parser for Dictionary-based Logging
9
10This uses the JSON database file to decode the binary
11log data taken directly from input serialport and print
12the log messages.
13"""
14
15import argparse
16import sys
17
18import live_log_parser
19
20
21def parse_args():
22    """Parse command line arguments"""
23    argparser = argparse.ArgumentParser(allow_abbrev=False)
24
25    argparser.add_argument("dbfile", help="Dictionary Logging Database file")
26    argparser.add_argument("serialPort", help="Port where the logs are generated")
27    argparser.add_argument("baudrate", help="Serial Port baud rate")
28    argparser.add_argument("--debug", action="store_true", help="Print extra debugging information")
29
30    return argparser.parse_args()
31
32
33def main():
34    """function of serial parser"""
35
36    print("This script is deprecated. Use 'live_log_parser.py' instead.", file=sys.stderr)
37
38    # Convert the arguments to the format expected by live_log_parser, and invoke it directly.
39    args = parse_args()
40
41    sys.argv = [
42        'live_log_parser.py',
43        args.dbfile,
44    ]
45    if args.debug:
46        sys.argv.append('--debug')
47
48    sys.argv += ['serial', args.serialPort, args.baudrate]
49
50    live_log_parser.main()
51
52
53if __name__ == "__main__":
54    main()
55