Skip to content

Write log file to OS-standard location instead of game directory#113

Open
MBurchard wants to merge 1 commit intonetniV:mainfrom
MBurchard:fix/log-path-os-standard
Open

Write log file to OS-standard location instead of game directory#113
MBurchard wants to merge 1 commit intonetniV:mainfrom
MBurchard:fix/log-path-os-standard

Conversation

@MBurchard
Copy link
Copy Markdown

Summary

The log file was written relative to the game's working directory, making it hard to find when debugging user-reported issues. This PR writes the log to OS-standard locations:

  • macOS: ~/Library/Logs/com.stfcmod.startrekpatch/community_patch.log
  • Windows: %LOCALAPPDATA%\stfcmod\Logs\community_patch.log

The log directory is created automatically on startup. The -ccm command line override continues to work as before.

Changes

  • file.cc: Platform-specific log path calculation in the default (non-override) case
  • file.h: Add ShlObj.h include for SHGetKnownFolderPath on Windows

Test plan

  • xmake build succeeds on macOS (arm64)
  • Log file appears at ~/Library/Logs/com.stfcmod.startrekpatch/community_patch.log
  • Log directory is created if it does not exist
  • Windows build and log path verification (not yet tested)

@MBurchard MBurchard changed the base branch from dev to main March 14, 2026 11:32
The log file was placed in the game's working directory, making it hard to find when debugging.

- macOS: ~/Library/Logs/com.stfcmod.startrekpatch/, Windows: %LOCALAPPDATA%/stfcmod/Logs/
- Create log directory on startup if it does not exist, keep existing behaviour for -ccm override
- Add ShlObj.h include for SHGetKnownFolderPath on Windows
@MBurchard MBurchard force-pushed the fix/log-path-os-standard branch from 44d0b8f to cbcaf63 Compare March 14, 2026 11:37
@a5ehren
Copy link
Copy Markdown
Contributor

a5ehren commented Mar 15, 2026

I'd probably prefer if this were MacOS only, the windows Mod just dumping in the same place as version.dll is fine.

@MBurchard
Copy link
Copy Markdown
Author

I disagree on principle. Log files shouldn't pollute the game directory on any platform. On Windows, %LOCALAPPDATA% is the standard location for application logs and avoids permission issues with Program Files paths.

That said, I don't want to hold up your work on #111. If you'd rather keep the Windows log path as-is, I'll close this PR and leave it to you.

@a5ehren
Copy link
Copy Markdown
Contributor

a5ehren commented Mar 16, 2026

Oh I'm not gonna touch the logging code at all. I'll leave this one up to @netniV

@netniV
Copy link
Copy Markdown
Owner

netniV commented Mar 16, 2026

When using the -ccm option, the log files are placed in the same directory as the toml file. This is our standard and makes life easier when requesting details from users who do not know what they are doing. So, whilst %appdata% may be standard for data under windows, I'm not convinced on making that change just yet.

But please try to convince me why that's important to move, and I may change my mind.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants