mirror of
https://github.com/markqvist/Sideband.git
synced 2024-12-28 08:59:30 -05:00
Squelch excessive kivy/jnius logging on Android. Live toggle debug logging for RNS and Sideband.
This commit is contained in:
parent
f531b2ecaa
commit
d87a58a51b
@ -5,7 +5,7 @@ __variant__ = "beta"
|
||||
|
||||
import sys
|
||||
import argparse
|
||||
parser = argparse.ArgumentParser(description="Reticulum Network Stack Daemon")
|
||||
parser = argparse.ArgumentParser(description="Sideband LXMF Client")
|
||||
parser.add_argument("-v", "--verbose", action='store_true', default=False, help="increase logging verbosity")
|
||||
parser.add_argument("--version", action="version", version="sideband {version}".format(version=__version__))
|
||||
args = parser.parse_args()
|
||||
@ -21,6 +21,27 @@ import threading
|
||||
import RNS.vendor.umsgpack as msgpack
|
||||
|
||||
from kivy.logger import Logger, LOG_LEVELS
|
||||
|
||||
# Squelch excessive method signature logging
|
||||
class redirect_log():
|
||||
def isEnabledFor(self, arg):
|
||||
return False
|
||||
def debug(self, arg):
|
||||
pass
|
||||
def trace(self, arg):
|
||||
pass
|
||||
def warning(self, arg):
|
||||
RNS.log("Kivy error: "+str(arg), RNS.LOG_WARNING)
|
||||
def critical(self, arg):
|
||||
RNS.log("Kivy error: "+str(arg), RNS.LOG_ERROR)
|
||||
|
||||
if RNS.vendor.platformutils.get_platform() == "android":
|
||||
import jnius.reflect
|
||||
def mod(method, name, signature):
|
||||
pass
|
||||
jnius.reflect.log_method = mod
|
||||
jnius.reflect.log = redirect_log()
|
||||
|
||||
if __debug_build__ or args.verbose:
|
||||
Logger.setLevel(LOG_LEVELS["debug"])
|
||||
else:
|
||||
@ -52,18 +73,6 @@ from mapview import CustomMapMarker
|
||||
from mapview.mbtsource import MBTilesMapSource
|
||||
from mapview.source import MapSource
|
||||
|
||||
class redirect_log():
|
||||
def isEnabledFor(self, arg):
|
||||
return False
|
||||
def debug(self, arg):
|
||||
pass
|
||||
def trace(self, arg):
|
||||
pass
|
||||
def warning(self, arg):
|
||||
RNS.log("Kivy error: "+str(arg), RNS.LOG_WARNING)
|
||||
def critical(self, arg):
|
||||
RNS.log("Kivy error: "+str(arg), RNS.LOG_ERROR)
|
||||
|
||||
import kivy.core.image
|
||||
kivy.core.image.Logger = redirect_log()
|
||||
|
||||
@ -1388,6 +1397,7 @@ class SidebandApp(MDApp):
|
||||
def save_debug(sender=None, event=None):
|
||||
self.sideband.config["debug"] = self.settings_screen.ids.settings_debug.active
|
||||
self.sideband.save_configuration()
|
||||
self.sideband._reticulum_log_debug(self.sideband.config["debug"])
|
||||
|
||||
def save_print_command(sender=None, event=None):
|
||||
if not sender.focus:
|
||||
|
@ -13,6 +13,20 @@ else:
|
||||
|
||||
if RNS.vendor.platformutils.get_platform() == "android":
|
||||
from jnius import autoclass, cast
|
||||
|
||||
# Squelch excessive method signature logging
|
||||
import jnius.reflect
|
||||
class redirect_log():
|
||||
def isEnabledFor(self, arg):
|
||||
return False
|
||||
def debug(self, arg):
|
||||
pass
|
||||
def mod(method, name, signature):
|
||||
pass
|
||||
jnius.reflect.log_method = mod
|
||||
jnius.reflect.log = redirect_log()
|
||||
############################################
|
||||
|
||||
from android import python_act
|
||||
android_api_version = autoclass('android.os.Build$VERSION').SDK_INT
|
||||
|
||||
|
@ -18,13 +18,18 @@ from .sense import Telemeter
|
||||
|
||||
if RNS.vendor.platformutils.get_platform() == "android":
|
||||
from jnius import autoclass, cast
|
||||
# Squelch excessive method signature logging
|
||||
import jnius.reflect
|
||||
class redirect_log():
|
||||
def isEnabledFor(self, arg):
|
||||
return False
|
||||
def debug(self, arg):
|
||||
pass
|
||||
def mod(method, name, signature):
|
||||
pass
|
||||
jnius.reflect.log_method = mod
|
||||
jnius.reflect.log = redirect_log()
|
||||
############################################
|
||||
|
||||
|
||||
class PropagationNodeDetector():
|
||||
@ -852,9 +857,6 @@ class SidebandCore():
|
||||
return self.getstate("app.active_conversation")
|
||||
|
||||
def setstate(self, prop, val):
|
||||
# TODO: remove
|
||||
# us = time.time()
|
||||
|
||||
if not RNS.vendor.platformutils.is_android():
|
||||
self.getstate_cache[prop] = val
|
||||
self._db_setstate(prop, val)
|
||||
@ -868,13 +870,6 @@ class SidebandCore():
|
||||
self.rpc_connection = multiprocessing.connection.Client(self.rpc_addr, authkey=self.rpc_key)
|
||||
self.rpc_connection.send({"setstate": (prop, val)})
|
||||
response = self.rpc_connection.recv()
|
||||
|
||||
# TODO: Remove
|
||||
# if response:
|
||||
# RNS.log("RPC setstate SUCCESS for "+str(prop)+"="+str(val)+" in "+RNS.prettytime(time.time()-us), RNS.LOG_WARNING)
|
||||
# else:
|
||||
# RNS.log("RPC setstate FAIL for "+str(prop)+"="+str(val)+" in "+RNS.prettytime(time.time()-us), RNS.LOG_WARNING)
|
||||
|
||||
return response
|
||||
except Exception as e:
|
||||
RNS.log("Error while setting state over RPC: "+str(e), RNS.LOG_DEBUG)
|
||||
@ -899,6 +894,27 @@ class SidebandCore():
|
||||
RNS.log("Error while setting telemetry over RPC: "+str(e), RNS.LOG_DEBUG)
|
||||
return False
|
||||
|
||||
def service_rpc_set_debug(self, debug):
|
||||
if not RNS.vendor.platformutils.is_android():
|
||||
pass
|
||||
else:
|
||||
if self.is_service:
|
||||
if debug:
|
||||
RNS.loglevel = 7
|
||||
else:
|
||||
RNS.loglevel = 2
|
||||
return True
|
||||
else:
|
||||
try:
|
||||
if self.rpc_connection == None:
|
||||
self.rpc_connection = multiprocessing.connection.Client(self.rpc_addr, authkey=self.rpc_key)
|
||||
self.rpc_connection.send({"set_debug": debug})
|
||||
response = self.rpc_connection.recv()
|
||||
return response
|
||||
except Exception as e:
|
||||
RNS.log("Error while setting log level over RPC: "+str(e), RNS.LOG_DEBUG)
|
||||
return False
|
||||
|
||||
def getstate(self, prop, allow_cache=False):
|
||||
# TODO: remove
|
||||
# us = time.time()
|
||||
@ -960,6 +976,10 @@ class SidebandCore():
|
||||
self.latest_telemetry = t
|
||||
self.latest_packed_telemetry = p
|
||||
connection.send(True)
|
||||
elif "set_debug" in call:
|
||||
self.service_rpc_set_debug(call["set_debug"])
|
||||
connection.send(True)
|
||||
|
||||
except Exception as e:
|
||||
RNS.log("Error on client RPC connection: "+str(e), RNS.LOG_ERROR)
|
||||
connection.close()
|
||||
@ -2198,7 +2218,17 @@ class SidebandCore():
|
||||
self.interface_local = None
|
||||
self.interface_local_adding = False
|
||||
|
||||
|
||||
def _reticulum_log_debug(self, debug=False):
|
||||
self.log_verbose = debug
|
||||
if self.log_verbose:
|
||||
selected_level = 7
|
||||
else:
|
||||
selected_level = 2
|
||||
|
||||
RNS.loglevel = selected_level
|
||||
if self.is_client:
|
||||
self.service_rpc_set_debug(debug)
|
||||
|
||||
def __start_jobs_immediate(self):
|
||||
if self.log_verbose:
|
||||
selected_level = 7
|
||||
|
Loading…
Reference in New Issue
Block a user