Added command line verbosity switch

This commit is contained in:
Mark Qvist 2022-10-03 18:29:54 +02:00
parent cf2a45e862
commit 1b64eb63f5
2 changed files with 26 additions and 9 deletions

View File

@ -1,15 +1,29 @@
__version__ = "0.1.9"
__variant__ = "beta"
import sys
import argparse
parser = argparse.ArgumentParser(description="Reticulum Network Stack Daemon")
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()
print(sys.argv)
sys.argv = [sys.argv[0]]
import RNS
import LXMF
import time
import sys
import os
import plyer
import base64
import threading
from kivy.logger import Logger, LOG_LEVELS
# Logger.setLevel(LOG_LEVELS["debug"])
Logger.setLevel(LOG_LEVELS["error"])
if args.verbose:
Logger.setLevel(LOG_LEVELS["debug"])
else:
Logger.setLevel(LOG_LEVELS["error"])
if RNS.vendor.platformutils.get_platform() != "android":
local = os.path.dirname(__file__)
@ -51,9 +65,6 @@ from kivy.metrics import dp
from kivymd.uix.button import MDFlatButton
from kivymd.uix.dialog import MDDialog
__version__ = "0.1.9"
__variant__ = "beta"
dark_theme_text_color = "ddd"
if RNS.vendor.platformutils.get_platform() == "android":
@ -78,7 +89,7 @@ class SidebandApp(MDApp):
if RNS.vendor.platformutils.get_platform() == "android":
self.sideband = SidebandCore(self, is_client=True, android_app_dir=self.app_dir)
else:
self.sideband = SidebandCore(self, is_client=False)
self.sideband = SidebandCore(self, is_client=False, verbose=args.verbose)
self.update_ui_theme()

View File

@ -71,7 +71,7 @@ class SidebandCore():
# stream logger
self.log_announce(destination_hash, app_data, dest_type=SidebandCore.aspect_filter)
def __init__(self, owner_app, is_service=False, is_client=False, android_app_dir=None):
def __init__(self, owner_app, is_service=False, is_client=False, android_app_dir=None, verbose=False):
self.is_service = is_service
self.is_client = is_client
@ -80,6 +80,7 @@ class SidebandCore():
else:
self.is_standalone = False
self.log_verbose = verbose
self.owner_app = owner_app
self.reticulum = None
@ -908,7 +909,12 @@ class SidebandCore():
self.service_thread.start()
def __start_jobs_immediate(self):
self.reticulum = RNS.Reticulum(configdir=self.rns_configdir, loglevel=2)
if self.log_verbose:
selected_level = 7
else:
selected_level = 2
self.reticulum = RNS.Reticulum(configdir=self.rns_configdir, loglevel=selected_level)
if RNS.vendor.platformutils.get_platform() == "android":
if not self.reticulum.is_connected_to_shared_instance: