From 18c17e23bbad7f4972540230bb1e3140eeca25cc Mon Sep 17 00:00:00 2001 From: Evan Sultanik Date: Tue, 26 Mar 2019 13:18:13 -0400 Subject: [PATCH] Adds a new commandline option to dump JSON RPC calls to a file (#57) --- etheno/__main__.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/etheno/__main__.py b/etheno/__main__.py index 63f3b4f..d2cf99b 100644 --- a/etheno/__main__.py +++ b/etheno/__main__.py @@ -11,6 +11,7 @@ from .echidna import echidna_exists, EchidnaPlugin, install_echidna from .etheno import app, EthenoView, GETH_DEFAULT_RPC_PORT, ETHENO, VERSION_NAME from .genesis import Account, make_accounts, make_genesis +from .jsonrpc import JSONRPCExportPlugin from .synchronization import AddressSynchronizingClient, RawTransactionClient from .utils import clear_directory, decode_value, find_open_port, format_hex_address, ynprompt from . import Etheno @@ -60,6 +61,7 @@ def main(argv = None): parser.add_argument('-l', '--log-level', type=str.upper, choices={'CRITICAL', 'ERROR', 'WARNING', 'INFO', 'DEBUG'}, default='INFO', help='Set Etheno\'s log level (default=INFO)') parser.add_argument('--log-file', type=str, default=None, help='Path to save all log output to a single file') parser.add_argument('--log-dir', type=str, default=None, help='Path to a directory in which to save all log output, divided by logging source') + parser.add_argument('-d', '--dump-jsonrpc', type=str, default=None, help='Path to a JSON file in which to dump all raw JSON RPC calls; if `--log-dir` is provided, the raw JSON RPC calls will additionally be dumped to `rpc.json` in the log directory.') parser.add_argument('-v', '--version', action='store_true', default=False, help='Print version information and exit') parser.add_argument('client', type=str, nargs='*', help='JSON RPC client URLs to multiplex; if no client is specified for --master, the first client in this list will default to the master (format="http://foo.com:8545/")') parser.add_argument('-s', '--master', type=str, default=None, help='A JSON RPC client to use as the master (format="http://foo.com:8545/")') @@ -103,7 +105,12 @@ def main(argv = None): if not args.log_file: # Also create a unified log in the log dir: ETHENO.logger.save_to_file(os.path.join(args.log_dir, 'Complete.log')) - + + ETHENO.add_plugin(JSONRPCExportPlugin(os.path.join(args.log_dir, 'rpc.json'))) + + if args.dump_jsonrpc is not None: + ETHENO.add_plugin(JSONRPCExportPlugin(args.dump_jsonrpc)) + # First, see if we need to install Echidna: if args.echidna: if not echidna_exists():