diff --git a/electrum/commands.py b/electrum/commands.py index 91f1b4053..32b89ff06 100644 --- a/electrum/commands.py +++ b/electrum/commands.py @@ -2085,9 +2085,6 @@ def add_global_options(parser, suppress=False): group.add_argument( "-v", dest="verbosity", default='', help=argparse.SUPPRESS if suppress else "Set verbosity (log levels)") - group.add_argument( - "-V", dest="verbosity_shortcuts", default='', - help=argparse.SUPPRESS if suppress else "Set verbosity (shortcut-filter list)") group.add_argument( "-D", "--dir", dest="electrum_path", help=argparse.SUPPRESS if suppress else "electrum directory") diff --git a/electrum/interface.py b/electrum/interface.py index 796a04afc..0edcb50ba 100644 --- a/electrum/interface.py +++ b/electrum/interface.py @@ -374,8 +374,6 @@ def _get_cert_path_for_host(*, config: 'SimpleConfig', host: str) -> str: class Interface(Logger): - LOGGING_SHORTCUT = 'i' - def __init__(self, *, network: 'Network', server: ServerAddr): self.ready = network.asyncio_loop.create_future() self.got_disconnected = asyncio.Event() diff --git a/electrum/lnpeer.py b/electrum/lnpeer.py index 75ab04184..5e99e1be6 100644 --- a/electrum/lnpeer.py +++ b/electrum/lnpeer.py @@ -70,8 +70,6 @@ LN_P2P_NETWORK_TIMEOUT = 20 class Peer(Logger, EventListener): # note: in general this class is NOT thread-safe. Most methods are assumed to be running on asyncio thread. - LOGGING_SHORTCUT = 'P' - ORDERED_MESSAGES = ( 'accept_channel', 'funding_signed', 'funding_created', 'accept_channel', 'closing_signed') SPAMMY_MESSAGES = ( diff --git a/electrum/lnwatcher.py b/electrum/lnwatcher.py index 6b0a5225e..455016163 100644 --- a/electrum/lnwatcher.py +++ b/electrum/lnwatcher.py @@ -20,8 +20,6 @@ if TYPE_CHECKING: class LNWatcher(Logger, EventListener): - LOGGING_SHORTCUT = 'W' - def __init__(self, lnworker: 'LNWallet'): self.lnworker = lnworker Logger.__init__(self) diff --git a/electrum/lnworker.py b/electrum/lnworker.py index d3c3d61a0..0259996d8 100644 --- a/electrum/lnworker.py +++ b/electrum/lnworker.py @@ -533,7 +533,6 @@ class LNGossip(LNWorker): independently of the active LNWallets. LNGossip keeps a curated batch of gossip in _forwarding_gossip that is fetched by the LNWallets for regular forwarding.""" max_age = 14*24*3600 - LOGGING_SHORTCUT = 'g' def __init__(self, config: 'SimpleConfig'): seed = os.urandom(32) diff --git a/electrum/logging.py b/electrum/logging.py index efe01f6c2..cb3ab6a20 100644 --- a/electrum/logging.py +++ b/electrum/logging.py @@ -152,7 +152,7 @@ def _configure_file_logging(log_directory: pathlib.Path, *, num_files_keep: int) console_stderr_handler = None -def _configure_stderr_logging(*, verbosity=None, verbosity_shortcuts=None): +def _configure_stderr_logging(*, verbosity=None): # log to stderr; by default only WARNING and higher global console_stderr_handler if console_stderr_handler is not None: @@ -160,14 +160,13 @@ def _configure_stderr_logging(*, verbosity=None, verbosity_shortcuts=None): return console_stderr_handler = logging.StreamHandler(sys.stderr) console_stderr_handler.setFormatter(console_formatter) - if not verbosity and not verbosity_shortcuts: + if not verbosity: console_stderr_handler.setLevel(logging.WARNING) root_logger.addHandler(console_stderr_handler) else: console_stderr_handler.setLevel(logging.DEBUG) root_logger.addHandler(console_stderr_handler) _process_verbosity_log_levels(verbosity) - _process_verbosity_filter_shortcuts(verbosity_shortcuts, handler=console_stderr_handler) if _inmemory_startup_logs: _inmemory_startup_logs.dump_to_target(console_stderr_handler) @@ -193,34 +192,6 @@ def _process_verbosity_log_levels(verbosity): raise Exception(f"invalid log filter: {filt}") -def _process_verbosity_filter_shortcuts(verbosity_shortcuts, *, handler: 'logging.Handler'): - if not isinstance(verbosity_shortcuts, str): - return - if len(verbosity_shortcuts) < 1: - return - # depending on first character being '^', either blacklist or whitelist - is_blacklist = verbosity_shortcuts[0] == '^' - if is_blacklist: - filters = verbosity_shortcuts[1:] - else: # whitelist - filters = verbosity_shortcuts[0:] - filt = ShortcutFilteringFilter(is_blacklist=is_blacklist, filters=filters) - # apply filter directly (and only!) on stderr handler - # note that applying on one of the root loggers directly would not work, - # see https://docs.python.org/3/howto/logging.html#logging-flow - handler.addFilter(filt) - - -class ShortcutInjectingFilter(logging.Filter): - - def __init__(self, *, shortcut: Optional[str]): - super().__init__() - self.__shortcut = shortcut - - def filter(self, record): - record.custom_shortcut = self.__shortcut - return True - class ShortcutFilteringFilter(logging.Filter): @@ -292,7 +263,6 @@ class Logger: # Single character short "name" for this class. # Can be used for filtering log lines. Does not need to be unique. - LOGGING_SHORTCUT = None # type: Optional[str] def __init__(self): self.logger = self.__get_logger_for_obj() @@ -310,8 +280,6 @@ class Logger: if diag_name: name += f".[{diag_name}]" logger = get_logger(name) - if self.LOGGING_SHORTCUT: - logger.addFilter(ShortcutInjectingFilter(shortcut=self.LOGGING_SHORTCUT)) return logger def diagnostic_name(self): @@ -322,10 +290,9 @@ def configure_logging(config: 'SimpleConfig', *, log_to_file: Optional[bool] = N from .util import is_android_debug_apk verbosity = config.get('verbosity') - verbosity_shortcuts = config.get('verbosity_shortcuts') if not verbosity and config.GUI_ENABLE_DEBUG_LOGS: verbosity = '*' - _configure_stderr_logging(verbosity=verbosity, verbosity_shortcuts=verbosity_shortcuts) + _configure_stderr_logging(verbosity=verbosity) if log_to_file is None: log_to_file = config.WRITE_LOGS_TO_DISK @@ -351,7 +318,7 @@ def configure_logging(config: 'SimpleConfig', *, log_to_file: Optional[bool] = N _logger.info(f"Electrum version: {ELECTRUM_VERSION} - https://electrum.org - {GIT_REPO_URL}") _logger.info(f"Python version: {sys.version}. On platform: {describe_os_version()}") _logger.info(f"Logging to file: {str(_logfile_path)}") - _logger.info(f"Log filters: verbosity {repr(verbosity)}, verbosity_shortcuts {repr(verbosity_shortcuts)}") + _logger.info(f"Log filters: verbosity {repr(verbosity)}") def get_logfile_path() -> Optional[pathlib.Path]: diff --git a/electrum/network.py b/electrum/network.py index 4a5243744..74abd009f 100644 --- a/electrum/network.py +++ b/electrum/network.py @@ -346,8 +346,6 @@ class Network(Logger, NetworkRetryManager[ServerAddr]): servers, each connected socket is handled by an Interface() object. """ - LOGGING_SHORTCUT = 'n' - taskgroup: Optional[OldTaskGroup] interface: Optional[Interface] interfaces: Dict[ServerAddr, Interface] diff --git a/electrum/plugin.py b/electrum/plugin.py index 0275e7008..0e2736274 100644 --- a/electrum/plugin.py +++ b/electrum/plugin.py @@ -70,7 +70,6 @@ PLUGIN_PASSWORD_VERSION = 1 class Plugins(DaemonThread): - LOGGING_SHORTCUT = 'p' pkgpath = os.path.dirname(plugins.__file__) # TODO: use XDG Base Directory Specification instead of hardcoding /etc keyfile_posix = '/etc/electrum/plugins_key' diff --git a/electrum/plugins/watchtower/watchtower.py b/electrum/plugins/watchtower/watchtower.py index b992a66a4..a8dacb686 100644 --- a/electrum/plugins/watchtower/watchtower.py +++ b/electrum/plugins/watchtower/watchtower.py @@ -64,8 +64,6 @@ class WatchtowerPlugin(BasePlugin): class WatchTower(Logger, EventListener): - LOGGING_SHORTCUT = 'W' - def __init__(self, network: 'Network'): Logger.__init__(self) self.adb = AddressSynchronizer(WalletDB('', storage=None, upgrade=True), network.config, name=self.diagnostic_name()) diff --git a/electrum/util.py b/electrum/util.py index ac4ffcced..c80b50f68 100644 --- a/electrum/util.py +++ b/electrum/util.py @@ -378,8 +378,6 @@ class DebugMem(ThreadJob): class DaemonThread(threading.Thread, Logger): """ daemon thread that terminates cleanly """ - LOGGING_SHORTCUT = 'd' - def __init__(self): threading.Thread.__init__(self) Logger.__init__(self) diff --git a/electrum/wallet.py b/electrum/wallet.py index 80c39dd88..998bef6a5 100644 --- a/electrum/wallet.py +++ b/electrum/wallet.py @@ -376,7 +376,6 @@ class Abstract_Wallet(ABC, Logger, EventListener): Completion states (watching-only, single account, no seed, etc) are handled inside classes. """ - LOGGING_SHORTCUT = 'w' max_change_outputs = 3 gap_limit_for_change = 10