From 29019724bdcda3901010d16decfa93bf5b6f7425 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Tue, 2 May 2023 16:42:04 +0200 Subject: [PATCH] Added verbosity argument to Reticulum instantiation. Fixes #238. --- RNS/Reticulum.py | 5 ++++- RNS/Utilities/rnsd.py | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/RNS/Reticulum.py b/RNS/Reticulum.py index 5364fdd..e0950c9 100755 --- a/RNS/Reticulum.py +++ b/RNS/Reticulum.py @@ -167,7 +167,7 @@ class Reticulum: RNS.exit() - def __init__(self,configdir=None, loglevel=None, logdest=None): + def __init__(self,configdir=None, loglevel=None, logdest=None, verbosity=None): """ Initialises and starts a Reticulum instance. This must be done before any other operations, and Reticulum will not @@ -211,6 +211,7 @@ class Reticulum: self.ifac_salt = Reticulum.IFAC_SALT self.requested_loglevel = loglevel + self.requested_verbosity = verbosity if self.requested_loglevel != None: if self.requested_loglevel > RNS.LOG_EXTREME: self.requested_loglevel = RNS.LOG_EXTREME @@ -337,6 +338,8 @@ class Reticulum: value = self.config["logging"][option] if option == "loglevel" and self.requested_loglevel == None: RNS.loglevel = int(value) + if self.requested_verbosity != None: + RNS.loglevel += self.requested_verbosity if RNS.loglevel < 0: RNS.loglevel = 0 if RNS.loglevel > 7: diff --git a/RNS/Utilities/rnsd.py b/RNS/Utilities/rnsd.py index ec56a4d..c170af4 100755 --- a/RNS/Utilities/rnsd.py +++ b/RNS/Utilities/rnsd.py @@ -30,15 +30,15 @@ from RNS._version import __version__ def program_setup(configdir, verbosity = 0, quietness = 0, service = False): - targetloglevel = 3+verbosity-quietness + targetverbosity = verbosity-quietness if service: targetlogdest = RNS.LOG_FILE - targetloglevel = None + targetverbosity = None else: targetlogdest = RNS.LOG_STDOUT - reticulum = RNS.Reticulum(configdir=configdir, loglevel=targetloglevel, logdest=targetlogdest) + reticulum = RNS.Reticulum(configdir=configdir, verbosity=targetverbosity, logdest=targetlogdest) if reticulum.is_connected_to_shared_instance: RNS.log("Started rnsd version {version} connected to another shared local instance, this is probably NOT what you want!".format(version=__version__), RNS.LOG_WARNING) else: