Skip to content

Commit 0c106e2

Browse files
pinheadmzwillcl-ark
authored andcommitted
warnetd: fix log file paths
1 parent fa20ac6 commit 0c106e2

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/warnet/warnetd.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,15 @@
3434

3535
WARNETD_PORT = 9276
3636

37-
# Determine the log file path based on XDG_STATE_HOME, or ~/.warnet
38-
log_file_dir = os.environ.get(
39-
"XDG_STATE_HOME", os.path.join(os.environ["HOME"], ".warnet")
40-
)
41-
LOG_FILE_PATH = os.path.join(log_file_dir, "warnet", "warnet.log")
37+
# Determine the log file path:
38+
basedir = os.environ.get("XDG_STATE_HOME")
39+
if basedir is None:
40+
# ~/.warnet/warnet.log
41+
basedir = os.path.join(os.environ["HOME"], ".warnet")
42+
else:
43+
# XDG_STATE_HOME / warnet / warnet.log
44+
basedir = os.path.join(basedir, "warnet")
45+
LOG_FILE_PATH = os.path.join(basedir, "warnet.log")
4246

4347
# Ensure the directory exists
4448
os.makedirs(os.path.dirname(LOG_FILE_PATH), exist_ok=True)

0 commit comments

Comments
 (0)