From d448ea5767fde975db048391febfd8c9fddbbaaf Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Tue, 25 Jun 2024 12:03:35 -0700 Subject: [PATCH] keep a symbolic link "latest" that points to the latest slog dir --- meshtastic/slog/slog.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/meshtastic/slog/slog.py b/meshtastic/slog/slog.py index 0dd0690..bc8df62 100644 --- a/meshtastic/slog/slog.py +++ b/meshtastic/slog/slog.py @@ -152,6 +152,13 @@ class LogSet: app_dir = platformdirs.user_data_dir(app_name, app_author) dir_name = f"{app_dir}/slogs/{datetime.now().strftime('%Y%m%d-%H%M%S')}" os.makedirs(dir_name, exist_ok=True) + + # Also make a 'latest' directory that always points to the most recent logs + # symlink might fail on some platforms, if it does fail silently + if os.path.exists(f"{app_dir}/slogs/latest"): + os.unlink(f"{app_dir}/slogs/latest") + os.symlink(dir_name, f"{app_dir}/slogs/latest", target_is_directory=True) + self.dir_name = dir_name logging.info(f"Writing slogs to {dir_name}")