Skip to content

Commit d448ea5

Browse files
committed
keep a symbolic link "latest" that points to the latest slog dir
1 parent 402622f commit d448ea5

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

meshtastic/slog/slog.py

+7
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,13 @@ def __init__(
152152
app_dir = platformdirs.user_data_dir(app_name, app_author)
153153
dir_name = f"{app_dir}/slogs/{datetime.now().strftime('%Y%m%d-%H%M%S')}"
154154
os.makedirs(dir_name, exist_ok=True)
155+
156+
# Also make a 'latest' directory that always points to the most recent logs
157+
# symlink might fail on some platforms, if it does fail silently
158+
if os.path.exists(f"{app_dir}/slogs/latest"):
159+
os.unlink(f"{app_dir}/slogs/latest")
160+
os.symlink(dir_name, f"{app_dir}/slogs/latest", target_is_directory=True)
161+
155162
self.dir_name = dir_name
156163

157164
logging.info(f"Writing slogs to {dir_name}")

0 commit comments

Comments
 (0)