Adjusted logging, added exception handler

This commit is contained in:
Mark Qvist 2023-11-07 00:11:37 +01:00
parent bd74b33094
commit 5228d5659e

View File

@ -1215,7 +1215,7 @@ class SidebandCore():
else: else:
if self.is_service: if self.is_service:
if debug: if debug:
RNS.loglevel = 7 RNS.loglevel = 6
else: else:
RNS.loglevel = 2 RNS.loglevel = 2
return True return True
@ -2382,6 +2382,7 @@ class SidebandCore():
time.sleep(SidebandCore.SERVICE_JOB_INTERVAL) time.sleep(SidebandCore.SERVICE_JOB_INTERVAL)
now = time.time() now = time.time()
try:
if hasattr(self, "interface_local"): if hasattr(self, "interface_local"):
if self.interface_local != None: if self.interface_local != None:
if self.interface_local.carrier_changed: if self.interface_local.carrier_changed:
@ -2407,6 +2408,12 @@ class SidebandCore():
self.owner_service.take_locks() self.owner_service.take_locks()
last_multicast_lock_check = now last_multicast_lock_check = now
except Exception as e:
import traceback
exception_info = "".join(traceback.TracebackException.from_exception(e).format())
RNS.log(f"An {str(type(e))} occurred while running interface checks: {str(e)}", RNS.LOG_ERROR)
RNS.log(exception_info, RNS.LOG_ERROR)
announce_wanted = self.getstate("wants.announce") announce_wanted = self.getstate("wants.announce")
announce_attached_interface = None announce_attached_interface = None
announce_delay = 0 announce_delay = 0
@ -2563,8 +2570,8 @@ class SidebandCore():
lastsync = self.getpersistent("lxmf.lastsync") lastsync = self.getpersistent("lxmf.lastsync")
nextsync = lastsync+syncinterval nextsync = lastsync+syncinterval
RNS.log("Last LXMF sync was "+RNS.prettytime(now-lastsync)+" ago", RNS.LOG_DEBUG) RNS.log("Last LXMF sync was "+RNS.prettytime(now-lastsync)+" ago", RNS.LOG_EXTREME)
RNS.log("Next LXMF sync is "+("in "+RNS.prettytime(nextsync-now) if nextsync-now > 0 else "now"), RNS.LOG_DEBUG) RNS.log("Next LXMF sync is "+("in "+RNS.prettytime(nextsync-now) if nextsync-now > 0 else "now"), RNS.LOG_EXTREME)
if now > nextsync: if now > nextsync:
if self.request_lxmf_sync(): if self.request_lxmf_sync():
RNS.log("Scheduled LXMF sync succeeded", RNS.LOG_DEBUG) RNS.log("Scheduled LXMF sync succeeded", RNS.LOG_DEBUG)
@ -2592,8 +2599,8 @@ class SidebandCore():
scheduled = next_send-now; blocked = self.telemetry_send_blocked_until-now scheduled = next_send-now; blocked = self.telemetry_send_blocked_until-now
next_send_in = max(scheduled, blocked) next_send_in = max(scheduled, blocked)
RNS.log("Last telemetry send was "+RNS.prettytime(now-last_send_timebase)+" ago", RNS.LOG_DEBUG) RNS.log("Last telemetry send was "+RNS.prettytime(now-last_send_timebase)+" ago", RNS.LOG_EXTREME)
RNS.log("Next telemetry send is "+("in "+RNS.prettytime(next_send_in) if next_send_in > 0 else "now"), RNS.LOG_DEBUG) RNS.log("Next telemetry send is "+("in "+RNS.prettytime(next_send_in) if next_send_in > 0 else "now"), RNS.LOG_EXTREME)
if now > last_send_timebase+send_interval and now > self.telemetry_send_blocked_until: if now > last_send_timebase+send_interval and now > self.telemetry_send_blocked_until:
RNS.log("Initiating telemetry send to collector", RNS.LOG_DEBUG) RNS.log("Initiating telemetry send to collector", RNS.LOG_DEBUG)
@ -2625,8 +2632,8 @@ class SidebandCore():
request_interval = self.config["telemetry_request_interval"] request_interval = self.config["telemetry_request_interval"]
next_request = last_request_timebase+request_interval next_request = last_request_timebase+request_interval
RNS.log("Last telemetry request was "+RNS.prettytime(now-last_request_timebase)+" ago", RNS.LOG_DEBUG) RNS.log("Last telemetry request was "+RNS.prettytime(now-last_request_timebase)+" ago", RNS.LOG_EXTREME)
RNS.log("Next telemetry request is "+("in "+RNS.prettytime(next_request-now) if next_request-now > 0 else "now"), RNS.LOG_DEBUG) RNS.log("Next telemetry request is "+("in "+RNS.prettytime(next_request-now) if next_request-now > 0 else "now"), RNS.LOG_EXTREME)
if now > last_request_timebase+request_interval: if now > last_request_timebase+request_interval:
RNS.log("Initiating telemetry request to collector", RNS.LOG_DEBUG) RNS.log("Initiating telemetry request to collector", RNS.LOG_DEBUG)
@ -2708,7 +2715,7 @@ class SidebandCore():
def _reticulum_log_debug(self, debug=False): def _reticulum_log_debug(self, debug=False):
self.log_verbose = debug self.log_verbose = debug
if self.log_verbose: if self.log_verbose:
selected_level = 7 selected_level = 6
else: else:
selected_level = 2 selected_level = 2
@ -2718,7 +2725,7 @@ class SidebandCore():
def __start_jobs_immediate(self): def __start_jobs_immediate(self):
if self.log_verbose: if self.log_verbose:
selected_level = 7 selected_level = 6
else: else:
selected_level = 2 selected_level = 2