Skip to content

Commit

Permalink
Add --quiet argument
Browse files Browse the repository at this point in the history
  • Loading branch information
Ouziel committed Mar 4, 2024
1 parent 1fb2062 commit d551ffa
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
8 changes: 5 additions & 3 deletions counterparty-cli/counterpartycli/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
APP_NAME = 'counterparty-server'

CONFIG_ARGS = [
[('-v', '--verbose'), {'dest': 'verbose', 'action': 'store_true', 'default': False, 'help': 'sets log level to DEBUG instead of WARNING'}],
[('-v', '--verbose'), {'dest': 'verbose', 'action': 'store_true', 'default': False, 'help': 'sets log level to DEBUG or INFO if --quiet is set'}],
[('--quiet',), {'dest': 'quiet', 'action': 'store_true', 'default': True, 'help': 'sets log level to ERROR or INFO if --verbose is set'}],
[('--testnet',), {'action': 'store_true', 'default': False, 'help': 'use {} testnet addresses and block numbers'.format(config.BTC_NAME)}],
[('--testcoin',), {'action': 'store_true', 'default': False, 'help': 'use the test {} network on every blockchain'.format(config.XCP_NAME)}],
[('--regtest',), {'action': 'store_true', 'default': False, 'help': 'use {} regtest addresses and block numbers'.format(config.BTC_NAME)}],
Expand Down Expand Up @@ -102,7 +103,7 @@ def main():

args = parser.parse_args()

log.set_up(log.ROOT_LOGGER, verbose=args.verbose, console_logfilter=os.environ.get('COUNTERPARTY_LOGGING', None))
log.set_up(log.ROOT_LOGGER, verbose=args.verbose, quiet=args.quiet, console_logfilter=os.environ.get('COUNTERPARTY_LOGGING', None))

logger.info('Running v{} of {}.'.format(APP_VERSION, APP_NAME))

Expand Down Expand Up @@ -148,7 +149,8 @@ def init_with_catch(fn, init_args):
requests_timeout=args.requests_timeout,
rpc_batch_size=args.rpc_batch_size,
check_asset_conservation=not args.no_check_asset_conservation,
force=args.force, verbose=args.verbose, console_logfilter=os.environ.get('COUNTERPARTY_LOGGING', None),
force=args.force, verbose=args.verbose, quiet=args.quiet,
console_logfilter=os.environ.get('COUNTERPARTY_LOGGING', None),
p2sh_dust_return_pubkey=args.p2sh_dust_return_pubkey,
utxo_locks_max_addresses=args.utxo_locks_max_addresses,
utxo_locks_max_age=args.utxo_locks_max_age,
Expand Down
9 changes: 5 additions & 4 deletions counterparty-lib/counterpartylib/lib/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,12 @@ def set_up_file_logging():
return
LOGGING_SETUP = True

log_level = logging.INFO
if quiet:
log_level = logging.ERROR
elif verbose:
if verbose and not quiet:
log_level = logging.DEBUG
elif verbose and quiet:
log_level = logging.INFO
else:
log_level = logging.ERROR
logger.setLevel(log_level)

# Console Logging
Expand Down
6 changes: 3 additions & 3 deletions counterparty-lib/counterpartylib/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def initialise_config(database_file=None, log_file=None, api_log_file=None,
rpc_host=None, rpc_port=None,
rpc_user=None, rpc_password=None,
rpc_no_allow_cors=False,
force=False, verbose=False, console_logfilter=None,
force=False, verbose=False, quiet=False, console_logfilter=None,
requests_timeout=config.DEFAULT_REQUESTS_TIMEOUT,
rpc_batch_size=config.DEFAULT_RPC_BATCH_SIZE,
check_asset_conservation=config.DEFAULT_CHECK_ASSET_CONSERVATION,
Expand Down Expand Up @@ -176,7 +176,8 @@ def initialise_config(database_file=None, log_file=None, api_log_file=None,

# Set up logging.
config.VERBOSE = verbose
log.set_up(log.ROOT_LOGGER, verbose=verbose, logfile=config.LOG, console_logfilter=console_logfilter)
config.QUIET = quiet
log.set_up(log.ROOT_LOGGER, verbose=verbose, quiet=quiet, logfile=config.LOG, console_logfilter=console_logfilter)
if config.LOG:
logger.debug('Writing server log to file: `{}`'.format(config.LOG))

Expand Down Expand Up @@ -494,7 +495,6 @@ def start_all(db):


def reparse(db, block_index):
connect_to_backend()
blocks.reparse(db, block_index=block_index)


Expand Down

0 comments on commit d551ffa

Please sign in to comment.