Browse Source
make "-v" (logging to stderr) work with commands
When running a command, file logging is disabled as every
command-invocation would create a new logfile. However if the user
explicitly sets "-v" on the commandline, there's no reason why that
shouldn't work.
patch-4
SomberNight
3 years ago
No known key found for this signature in database
GPG Key ID: B33B5F232C6271E9
2 changed files with
13 additions and
8 deletions
electrum/logging.py
run_electrum
@ -9,10 +9,13 @@ import sys
import pathlib
import pathlib
import os
import os
import platform
import platform
from typing import Optional
from typing import Optional , TYPE_CHECKING
import copy
import copy
import subprocess
import subprocess
if TYPE_CHECKING :
from . simple_config import SimpleConfig
class LogFormatterForFiles ( logging . Formatter ) :
class LogFormatterForFiles ( logging . Formatter ) :
@ -306,11 +309,12 @@ class Logger:
return ' '
return ' '
def configure_logging ( config ) :
def configure_logging ( config : ' SimpleConfig ' , * , log_to_file : Optional [ bool ] = None ) - > None :
verbosity = config . get ( ' verbosity ' )
verbosity = config . get ( ' verbosity ' )
verbosity_shortcuts = config . get ( ' verbosity_shortcuts ' )
verbosity_shortcuts = config . get ( ' verbosity_shortcuts ' )
_configure_stderr_logging ( verbosity = verbosity , verbosity_shortcuts = verbosity_shortcuts )
_configure_stderr_logging ( verbosity = verbosity , verbosity_shortcuts = verbosity_shortcuts )
if log_to_file is None :
log_to_file = config . get ( ' log_to_file ' , False )
log_to_file = config . get ( ' log_to_file ' , False )
is_android = ' ANDROID_DATA ' in os . environ
is_android = ' ANDROID_DATA ' in os . environ
if is_android :
if is_android :
@ -454,6 +454,7 @@ def handle_cmd(*, cmdname: str, config: 'SimpleConfig', config_options: dict):
sys_exit(1)
sys_exit(1)
else:
else:
# command line
# command line
configure_logging(config, log_to_file=False) # don't spam logfiles for each client-side RPC, but support "-v"
cmd = known_commands[cmdname]
cmd = known_commands[cmdname]
wallet_path = config.get_wallet_path()
wallet_path = config.get_wallet_path()
if not config.get('offline'):
if not config.get('offline'):