Browse Source

PrintError: display verbosity filter

3.3.3.1
ThomasV 6 years ago
parent
commit
a266de6735
  1. 1
      electrum/interface.py
  2. 14
      electrum/util.py

1
electrum/interface.py

@ -138,6 +138,7 @@ def serialize_server(host: str, port: Union[str, int], protocol: str) -> str:
class Interface(PrintError): class Interface(PrintError):
verbosity_filter = 'i'
def __init__(self, network: 'Network', server: str, config_path, proxy: dict): def __init__(self, network: 'Network', server: str, config_path, proxy: dict):
self.ready = asyncio.Future() self.ready = asyncio.Future()

14
electrum/util.py

@ -183,17 +183,23 @@ class PrintError(object):
verbosity_filter = '' verbosity_filter = ''
def diagnostic_name(self): def diagnostic_name(self):
return self.__class__.__name__ return ''
def log_name(self):
msg = self.verbosity_filter or self.__class__.__name__
d = self.diagnostic_name()
if d: msg += "][" + d
return "[%s]" % msg
def print_error(self, *msg): def print_error(self, *msg):
if self.verbosity_filter in verbosity or verbosity == '*': if self.verbosity_filter in verbosity or verbosity == '*':
print_error("[%s]" % self.diagnostic_name(), *msg) print_error(self.log_name(), *msg)
def print_stderr(self, *msg): def print_stderr(self, *msg):
print_stderr("[%s]" % self.diagnostic_name(), *msg) print_stderr(self.log_name(), *msg)
def print_msg(self, *msg): def print_msg(self, *msg):
print_msg("[%s]" % self.diagnostic_name(), *msg) print_msg(self.log_name(), *msg)
class ThreadJob(PrintError): class ThreadJob(PrintError):
"""A job that is run periodically from a thread's main loop. run() is """A job that is run periodically from a thread's main loop. run() is

Loading…
Cancel
Save