1
0

rm verbosity_shortcuts option (unused, redundant)

This commit is contained in:
ThomasV
2025-05-29 16:19:33 +02:00
parent 743f5c8311
commit 853b793bef
11 changed files with 4 additions and 55 deletions

View File

@@ -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")

View File

@@ -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()

View File

@@ -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 = (

View File

@@ -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)

View File

@@ -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)

View File

@@ -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]:

View File

@@ -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]

View File

@@ -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'

View File

@@ -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())

View File

@@ -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)

View File

@@ -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