Updated logging

This commit is contained in:
Mark Qvist 2025-01-21 23:55:49 +01:00
parent 06de7f4a3d
commit fd6d8ffff8
2 changed files with 12 additions and 12 deletions

View File

@ -302,7 +302,7 @@ class Reticulum:
time.sleep(1.5) time.sleep(1.5)
self.__apply_config() self.__apply_config()
RNS.log(f"Utilising cryptography backend \"{RNS.Cryptography.Provider.backend()}\"", RNS.LOG_VERBOSE) RNS.log(f"Utilising cryptography backend \"{RNS.Cryptography.Provider.backend()}\"", RNS.LOG_DEBUG)
RNS.log(f"Configuration loaded from {self.configpath}", RNS.LOG_VERBOSE) RNS.log(f"Configuration loaded from {self.configpath}", RNS.LOG_VERBOSE)
RNS.Identity.load_known_destinations() RNS.Identity.load_known_destinations()

View File

@ -81,21 +81,21 @@ logging_lock = threading.Lock()
def loglevelname(level): def loglevelname(level):
if (level == LOG_CRITICAL): if (level == LOG_CRITICAL):
return "Critical" return "[Critical]"
if (level == LOG_ERROR): if (level == LOG_ERROR):
return "Error" return "[Error] "
if (level == LOG_WARNING): if (level == LOG_WARNING):
return "Warning" return "[Warning] "
if (level == LOG_NOTICE): if (level == LOG_NOTICE):
return "Notice" return "[Notice] "
if (level == LOG_INFO): if (level == LOG_INFO):
return "Info" return "[Info] "
if (level == LOG_VERBOSE): if (level == LOG_VERBOSE):
return "Verbose" return "[Verbose] "
if (level == LOG_DEBUG): if (level == LOG_DEBUG):
return "Debug" return "[Debug] "
if (level == LOG_EXTREME): if (level == LOG_EXTREME):
return "Extra" return "[Extra] "
return "Unknown" return "Unknown"
@ -118,12 +118,12 @@ def log(msg, level=3, _override_destination = False, pt=False):
msg = str(msg) msg = str(msg)
if loglevel >= level: if loglevel >= level:
if pt: if pt:
logstring = "["+precise_timestamp_str(time.time())+"] ["+loglevelname(level)+"] "+msg logstring = "["+precise_timestamp_str(time.time())+"] "+loglevelname(level)+" "+msg
else: else:
if not compact_log_fmt: if not compact_log_fmt:
logstring = "["+timestamp_str(time.time())+"] ["+loglevelname(level)+"] "+msg logstring = "["+timestamp_str(time.time())+"] "+loglevelname(level)+" "+msg
else: else:
logstring = "["+timestamp_str(time.time())+"] "+msg logstring = "["+timestamp_str(time.time())+" "+msg
with logging_lock: with logging_lock:
if (logdest == LOG_STDOUT or _always_override_destination or _override_destination): if (logdest == LOG_STDOUT or _always_override_destination or _override_destination):