mirror of
https://github.com/markqvist/NomadNet.git
synced 2025-05-18 05:40:26 -04:00
Added log to console option for daemon mode
This commit is contained in:
parent
a6eac0d7ce
commit
7814712118
3 changed files with 24 additions and 7 deletions
|
@ -46,7 +46,7 @@ class NomadNetworkApp:
|
||||||
if issubclass(e_type, KeyboardInterrupt):
|
if issubclass(e_type, KeyboardInterrupt):
|
||||||
sys.__excepthook__(e_type, e_value, e_traceback)
|
sys.__excepthook__(e_type, e_value, e_traceback)
|
||||||
|
|
||||||
def __init__(self, configdir = None, rnsconfigdir = None, daemon = False):
|
def __init__(self, configdir = None, rnsconfigdir = None, daemon = False, force_console = False):
|
||||||
self.version = __version__
|
self.version = __version__
|
||||||
self.enable_client = False
|
self.enable_client = False
|
||||||
self.enable_node = False
|
self.enable_node = False
|
||||||
|
@ -59,6 +59,11 @@ class NomadNetworkApp:
|
||||||
else:
|
else:
|
||||||
self.configdir = configdir
|
self.configdir = configdir
|
||||||
|
|
||||||
|
if force_console:
|
||||||
|
self.force_console_log = True
|
||||||
|
else:
|
||||||
|
self.force_console_log = False
|
||||||
|
|
||||||
if NomadNetworkApp._shared_instance == None:
|
if NomadNetworkApp._shared_instance == None:
|
||||||
NomadNetworkApp._shared_instance = self
|
NomadNetworkApp._shared_instance = self
|
||||||
|
|
||||||
|
@ -490,7 +495,7 @@ class NomadNetworkApp:
|
||||||
if RNS.loglevel > 7:
|
if RNS.loglevel > 7:
|
||||||
RNS.loglevel = 7
|
RNS.loglevel = 7
|
||||||
if option == "destination":
|
if option == "destination":
|
||||||
if value.lower() == "file":
|
if value.lower() == "file" and not self.force_console_log:
|
||||||
RNS.logdest = RNS.LOG_FILE
|
RNS.logdest = RNS.LOG_FILE
|
||||||
if "logfile" in self.config["logging"]:
|
if "logfile" in self.config["logging"]:
|
||||||
self.logfilepath = self.config["logging"]["logfile"]
|
self.logfilepath = self.config["logging"]["logfile"]
|
||||||
|
|
|
@ -7,16 +7,22 @@ import argparse
|
||||||
import nomadnet
|
import nomadnet
|
||||||
|
|
||||||
|
|
||||||
def program_setup(configdir, rnsconfigdir, daemon):
|
def program_setup(configdir, rnsconfigdir, daemon, console):
|
||||||
app = nomadnet.NomadNetworkApp(configdir = configdir, rnsconfigdir = rnsconfigdir, daemon = daemon)
|
app = nomadnet.NomadNetworkApp(
|
||||||
|
configdir = configdir,
|
||||||
|
rnsconfigdir = rnsconfigdir,
|
||||||
|
daemon = daemon,
|
||||||
|
force_console = console,
|
||||||
|
)
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
try:
|
try:
|
||||||
parser = argparse.ArgumentParser(description="Nomad Network Client")
|
parser = argparse.ArgumentParser(description="Nomad Network Client")
|
||||||
parser.add_argument("--config", action="store", default=None, help="path to alternative Nomad Network config directory", type=str)
|
parser.add_argument("--config", action="store", default=None, help="path to alternative Nomad Network config directory", type=str)
|
||||||
parser.add_argument("--rnsconfig", action="store", default=None, help="path to alternative Reticulum config directory", type=str)
|
parser.add_argument("--rnsconfig", action="store", default=None, help="path to alternative Reticulum config directory", type=str)
|
||||||
parser.add_argument("-d", "--daemon", action="store_true", default=False, help="run Nomad Network in daemon mode")
|
|
||||||
parser.add_argument("-t", "--textui", action="store_true", default=False, help="run Nomad Network in text-UI mode")
|
parser.add_argument("-t", "--textui", action="store_true", default=False, help="run Nomad Network in text-UI mode")
|
||||||
|
parser.add_argument("-d", "--daemon", action="store_true", default=False, help="run Nomad Network in daemon mode")
|
||||||
|
parser.add_argument("-c", "--console", action="store_true", default=False, help="in daemon mode, log to console instead of file")
|
||||||
parser.add_argument("--version", action="version", version="Nomad Network Client {version}".format(version=__version__))
|
parser.add_argument("--version", action="version", version="Nomad Network Client {version}".format(version=__version__))
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
@ -31,15 +37,18 @@ def main():
|
||||||
else:
|
else:
|
||||||
rnsconfigarg = None
|
rnsconfigarg = None
|
||||||
|
|
||||||
|
console = False
|
||||||
if args.daemon:
|
if args.daemon:
|
||||||
daemon = True
|
daemon = True
|
||||||
|
if args.console:
|
||||||
|
console = True
|
||||||
else:
|
else:
|
||||||
daemon = False
|
daemon = False
|
||||||
|
|
||||||
if args.textui:
|
if args.textui:
|
||||||
daemon = False
|
daemon = False
|
||||||
|
|
||||||
program_setup(configarg, rnsconfigarg, daemon)
|
program_setup(configarg, rnsconfigarg, daemon, console)
|
||||||
|
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print("")
|
print("")
|
||||||
|
|
|
@ -10,7 +10,10 @@ class NoneUI:
|
||||||
self.app = NomadNetworkApp.get_shared_instance()
|
self.app = NomadNetworkApp.get_shared_instance()
|
||||||
self.app.ui = self
|
self.app.ui = self
|
||||||
|
|
||||||
RNS.log("Nomad Network started in daemon mode, all further messages are logged to "+str(self.app.logfilepath), RNS.LOG_INFO, _override_destination=True)
|
if not self.app.force_console_log:
|
||||||
|
RNS.log("Nomad Network started in daemon mode, all further messages are logged to "+str(self.app.logfilepath), RNS.LOG_INFO, _override_destination=True)
|
||||||
|
else:
|
||||||
|
RNS.log("Nomad Network daemon started", RNS.LOG_INFO)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
time.sleep(1)
|
time.sleep(1)
|
Loading…
Add table
Add a link
Reference in a new issue