mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-23 17:47:31 +00:00
Whitelist classes in verbose (-v) option
This commit is contained in:
parent
8f17f38b02
commit
780b2d067c
7 changed files with 16 additions and 10 deletions
|
@ -829,7 +829,7 @@ def add_network_options(parser):
|
||||||
|
|
||||||
def add_global_options(parser):
|
def add_global_options(parser):
|
||||||
group = parser.add_argument_group('global options')
|
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("-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("-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")
|
group.add_argument("-w", "--wallet", dest="wallet_path", help="wallet path")
|
||||||
|
|
|
@ -59,6 +59,7 @@ def Connection(server, queue, config_path):
|
||||||
|
|
||||||
|
|
||||||
class TcpConnection(threading.Thread, util.PrintError):
|
class TcpConnection(threading.Thread, util.PrintError):
|
||||||
|
verbosity_filter = 'i'
|
||||||
|
|
||||||
def __init__(self, server, queue, config_path):
|
def __init__(self, server, queue, config_path):
|
||||||
threading.Thread.__init__(self)
|
threading.Thread.__init__(self)
|
||||||
|
|
|
@ -170,6 +170,7 @@ class Network(util.DaemonThread):
|
||||||
get_parameters(), get_server_height(), get_status_value(),
|
get_parameters(), get_server_height(), get_status_value(),
|
||||||
is_connected(), set_parameters(), stop()
|
is_connected(), set_parameters(), stop()
|
||||||
"""
|
"""
|
||||||
|
verbosity_filter = 'n'
|
||||||
|
|
||||||
def __init__(self, config=None):
|
def __init__(self, config=None):
|
||||||
if config is None:
|
if config is None:
|
||||||
|
|
|
@ -43,6 +43,7 @@ hooks = {}
|
||||||
|
|
||||||
|
|
||||||
class Plugins(DaemonThread):
|
class Plugins(DaemonThread):
|
||||||
|
verbosity_filter = 'p'
|
||||||
|
|
||||||
@profiler
|
@profiler
|
||||||
def __init__(self, config, is_local, gui_name):
|
def __init__(self, config, is_local, gui_name):
|
||||||
|
|
|
@ -164,12 +164,14 @@ class MyEncoder(json.JSONEncoder):
|
||||||
|
|
||||||
class PrintError(object):
|
class PrintError(object):
|
||||||
'''A handy base class'''
|
'''A handy base class'''
|
||||||
|
verbosity_filter = ''
|
||||||
|
|
||||||
def diagnostic_name(self):
|
def diagnostic_name(self):
|
||||||
return self.__class__.__name__
|
return self.__class__.__name__
|
||||||
|
|
||||||
def print_error(self, *msg):
|
def print_error(self, *msg):
|
||||||
# only prints with --verbose flag
|
if self.verbosity_filter in verbosity:
|
||||||
print_error("[%s]" % self.diagnostic_name(), *msg)
|
print_stderr("[%s]" % self.diagnostic_name(), *msg)
|
||||||
|
|
||||||
def print_stderr(self, *msg):
|
def print_stderr(self, *msg):
|
||||||
print_stderr("[%s]" % self.diagnostic_name(), *msg)
|
print_stderr("[%s]" % self.diagnostic_name(), *msg)
|
||||||
|
@ -213,6 +215,7 @@ class DebugMem(ThreadJob):
|
||||||
|
|
||||||
class DaemonThread(threading.Thread, PrintError):
|
class DaemonThread(threading.Thread, PrintError):
|
||||||
""" daemon thread that terminates cleanly """
|
""" daemon thread that terminates cleanly """
|
||||||
|
verbosity_filter = 'd'
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
threading.Thread.__init__(self)
|
threading.Thread.__init__(self)
|
||||||
|
@ -263,15 +266,14 @@ class DaemonThread(threading.Thread, PrintError):
|
||||||
self.print_error("stopped")
|
self.print_error("stopped")
|
||||||
|
|
||||||
|
|
||||||
# TODO: disable
|
verbosity = ''
|
||||||
is_verbose = True
|
|
||||||
def set_verbosity(b):
|
def set_verbosity(b):
|
||||||
global is_verbose
|
global verbosity
|
||||||
is_verbose = b
|
verbosity = b
|
||||||
|
|
||||||
|
|
||||||
def print_error(*args):
|
def print_error(*args):
|
||||||
if not is_verbose: return
|
if not verbosity: return
|
||||||
print_stderr(*args)
|
print_stderr(*args)
|
||||||
|
|
||||||
def print_stderr(*args):
|
def print_stderr(*args):
|
||||||
|
|
|
@ -165,6 +165,7 @@ class Abstract_Wallet(AddressSynchronizer):
|
||||||
|
|
||||||
max_change_outputs = 3
|
max_change_outputs = 3
|
||||||
gap_limit_for_change = 6
|
gap_limit_for_change = 6
|
||||||
|
verbosity_filter = 'w'
|
||||||
|
|
||||||
def __init__(self, storage):
|
def __init__(self, storage):
|
||||||
AddressSynchronizer.__init__(self, storage)
|
AddressSynchronizer.__init__(self, storage)
|
||||||
|
|
|
@ -355,7 +355,7 @@ if __name__ == '__main__':
|
||||||
# config is an object passed to the various constructors (wallet, interface, gui)
|
# config is an object passed to the various constructors (wallet, interface, gui)
|
||||||
if is_android:
|
if is_android:
|
||||||
config_options = {
|
config_options = {
|
||||||
'verbose': True,
|
'verbosity': '',
|
||||||
'cmd': 'gui',
|
'cmd': 'gui',
|
||||||
'gui': 'kivy',
|
'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')
|
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
|
# 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
|
# check uri
|
||||||
uri = config_options.get('url')
|
uri = config_options.get('url')
|
||||||
|
|
Loading…
Add table
Reference in a new issue