Added verbosity argument to Reticulum instantiation. Fixes #238.

This commit is contained in:
Mark Qvist 2023-05-02 16:42:04 +02:00
parent fac4973329
commit 29019724bd
2 changed files with 7 additions and 4 deletions

View File

@ -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:

View File

@ -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: