From b4e15503c1fd73dee35d5c30c8730ad3329d8a1b Mon Sep 17 00:00:00 2001 From: Victor Alexeev Date: Thu, 28 May 2026 16:52:39 +0200 Subject: [PATCH] Added option to log without timestamps --- RNS/Reticulum.py | 3 +++ RNS/Utilities/rnsd.py | 6 ++++++ RNS/__init__.py | 5 +++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/RNS/Reticulum.py b/RNS/Reticulum.py index ab131e5a..3c3b8904 100755 --- a/RNS/Reticulum.py +++ b/RNS/Reticulum.py @@ -458,6 +458,9 @@ class Reticulum: RNS.loglevel = 0 if RNS.loglevel > 7: RNS.loglevel = 7 + elif option == "logtimestamps": + value = self.config["logging"].as_bool(option) + RNS.logtimestamps = bool(value) if "reticulum" in self.config: for option in self.config["reticulum"]: diff --git a/RNS/Utilities/rnsd.py b/RNS/Utilities/rnsd.py index b365ecca..af2f60ba 100755 --- a/RNS/Utilities/rnsd.py +++ b/RNS/Utilities/rnsd.py @@ -262,6 +262,12 @@ instance_name = default loglevel = 4 +# You can disable timestamp inclusion in logs. Useful if +# you want to use an external logging tool that provides +# its own timestamps or custom formatting. + +# logtimestamps = no + # The interfaces section defines the physical and virtual # interfaces Reticulum will use to communicate on. This diff --git a/RNS/__init__.py b/RNS/__init__.py index 22859b4f..7aea1fce 100755 --- a/RNS/__init__.py +++ b/RNS/__init__.py @@ -82,6 +82,7 @@ loglevel = LOG_NOTICE logfile = None logdest = LOG_STDOUT logcall = None +logtimestamps = True logtimefmt = "%Y-%m-%d %H:%M:%S" logtimefmt_p = "%H:%M:%S.%f" compact_log_fmt = False @@ -127,8 +128,8 @@ def log(msg, level=3, _override_destination = False, pt=False): if loglevel >= level: if pt: logstring = "["+precise_timestamp_str(time.time())+"] "+loglevelname(level)+" "+msg else: - if not compact_log_fmt: logstring = "["+timestamp_str(time.time())+"] "+loglevelname(level)+" "+msg - else: logstring = "["+timestamp_str(time.time())+"] "+msg + if not compact_log_fmt: logstring = ("["+timestamp_str(time.time())+"] " if logtimestamps else "")+loglevelname(level)+" "+msg + else: logstring = ("["+timestamp_str(time.time())+"] " if logtimestamps else "")+msg with logging_lock: if (logdest == LOG_STDOUT or _always_override_destination or _override_destination):