electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 780b2d067c1ade3575e9511e9e3c71a4a39f50c2
parent 8f17f38b02406ff4f90940ea66dda4b5f93bf227
Author: Janus <ysangkok@gmail.com>
Date:   Wed, 18 Jul 2018 13:31:41 +0200

Whitelist classes in verbose (-v) option

Diffstat:
Melectrum/commands.py | 2+-
Melectrum/interface.py | 1+
Melectrum/network.py | 1+
Melectrum/plugin.py | 1+
Melectrum/util.py | 16+++++++++-------
Melectrum/wallet.py | 1+
Mrun_electrum | 4++--
7 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/electrum/commands.py b/electrum/commands.py @@ -829,7 +829,7 @@ def add_network_options(parser): def add_global_options(parser): group = parser.add_argument_group('global options') - group.add_argument("-v", "--verbose", action="store_true", dest="verbose", default=False, help="Show debugging information") + group.add_argument("-v", "--verbosity", dest="verbosity", default='', help="Set verbosity filter") group.add_argument("-D", "--dir", dest="electrum_path", help="electrum directory") group.add_argument("-P", "--portable", action="store_true", dest="portable", default=False, help="Use local 'electrum_data' directory") group.add_argument("-w", "--wallet", dest="wallet_path", help="wallet path") diff --git a/electrum/interface.py b/electrum/interface.py @@ -59,6 +59,7 @@ def Connection(server, queue, config_path): class TcpConnection(threading.Thread, util.PrintError): + verbosity_filter = 'i' def __init__(self, server, queue, config_path): threading.Thread.__init__(self) diff --git a/electrum/network.py b/electrum/network.py @@ -170,6 +170,7 @@ class Network(util.DaemonThread): get_parameters(), get_server_height(), get_status_value(), is_connected(), set_parameters(), stop() """ + verbosity_filter = 'n' def __init__(self, config=None): if config is None: diff --git a/electrum/plugin.py b/electrum/plugin.py @@ -43,6 +43,7 @@ hooks = {} class Plugins(DaemonThread): + verbosity_filter = 'p' @profiler def __init__(self, config, is_local, gui_name): diff --git a/electrum/util.py b/electrum/util.py @@ -164,12 +164,14 @@ class MyEncoder(json.JSONEncoder): class PrintError(object): '''A handy base class''' + verbosity_filter = '' + def diagnostic_name(self): return self.__class__.__name__ def print_error(self, *msg): - # only prints with --verbose flag - print_error("[%s]" % self.diagnostic_name(), *msg) + if self.verbosity_filter in verbosity: + print_stderr("[%s]" % self.diagnostic_name(), *msg) def print_stderr(self, *msg): print_stderr("[%s]" % self.diagnostic_name(), *msg) @@ -213,6 +215,7 @@ class DebugMem(ThreadJob): class DaemonThread(threading.Thread, PrintError): """ daemon thread that terminates cleanly """ + verbosity_filter = 'd' def __init__(self): threading.Thread.__init__(self) @@ -263,15 +266,14 @@ class DaemonThread(threading.Thread, PrintError): self.print_error("stopped") -# TODO: disable -is_verbose = True +verbosity = '' def set_verbosity(b): - global is_verbose - is_verbose = b + global verbosity + verbosity = b def print_error(*args): - if not is_verbose: return + if not verbosity: return print_stderr(*args) def print_stderr(*args): diff --git a/electrum/wallet.py b/electrum/wallet.py @@ -165,6 +165,7 @@ class Abstract_Wallet(AddressSynchronizer): max_change_outputs = 3 gap_limit_for_change = 6 + verbosity_filter = 'w' def __init__(self, storage): AddressSynchronizer.__init__(self, storage) diff --git a/run_electrum b/run_electrum @@ -355,7 +355,7 @@ if __name__ == '__main__': # config is an object passed to the various constructors (wallet, interface, gui) if is_android: config_options = { - 'verbose': True, + 'verbosity': '', 'cmd': 'gui', 'gui': 'kivy', } @@ -376,7 +376,7 @@ if __name__ == '__main__': config_options['electrum_path'] = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'electrum_data') # kivy sometimes freezes when we write to sys.stderr - set_verbosity(config_options.get('verbose') and config_options.get('gui')!='kivy') + set_verbosity(config_options.get('verbosity') if config_options.get('gui') != 'kivy' else '') # check uri uri = config_options.get('url')