soroban-cli
soroban-cli copied to clipboard
CLI: Add verbose option that logs requests/responses
It would be helpful at times if the CLI could output additional information about what it's doing and what it is sending and receiving to the network. This would be especially helpful when debugging.
We could add a --verbose CLI option that enables additional logs to stderr. The logs would be sent to stderr so as not to interfere with any output on stdout intended to be read by other programs.
At minimum enabling verbose would output any requests sent and any responses received from any server the CLI interacts with.
Enabling verbose could also output anything else that we might find to be useful when debugging.
There was a discussion related to this at https://discord.com/channels/897514728459468821/966788672164855829/1093645380022976623.
Looking into this I've started to use tracing to handle the logging. Tracing offers different levels of logs. Any output produced by the excecution can be logged under INFO. Currently for some events and outputs we have flags, e.g. events, footprint. Instead we can use one argument for the filter for them; this should make API cleaner and new outputs can be added without changing the API. Then for anything more verbose we use TRACING.
Another benefit of tracing is we can use different subscribers for the logs, allowing for non-blocking writes to files and stderr.
This ia a great feature! perhaps instead of --very-verbose this feature might be handled using log levels? log-level=ERROR|INFO|DEBUG|TRACE.
-v: --log-level: ERROR-vv(very verbose): --log-level: INFO-vv --log-level [specify]: --log-level [DEBUG|TRACE]. level depends on -vv being there.
Currently it's:
/// Filter logs output. To turn on "soroban_cli::log::footprint=debug" or off "=off". Can also use env var `RUST_LOG`.
#[arg(long, short = 'f')]
pub filter_logs: Vec<String>,
/// Do not write logs to stderr including `INFO`
#[arg(long, short = 'q')]
pub quiet: bool,
/// Log DEBUG events
#[arg(long, short = 'v')]
pub verbose: bool,
/// Log DEBUG and TRACE events
#[arg(long, alias = "vv")]
pub very_verbose: bool,
It assumes INFO to be the default, --quiet if that is too much. Then you can use RUST_LOG or --filter-log to set the log level.--quiet --filter-log soroban_cli=debug
It's difficult to debug the CLI / RPC when things aren't working as expected without this feature. I suggest we prioritize adding it. It seems like a small effort change, and would significantly aid debugging. cc @mollykarcher