fix(plugin): use autostart_log instead of mangohudctl, improve log search
This commit is contained in:
+12
-13
@@ -186,12 +186,11 @@ class Plugin:
|
||||
os.makedirs(config_dir, exist_ok=True)
|
||||
|
||||
# MangoHud config that enables logging with the metrics we need.
|
||||
# output_folder is required for logging to work.
|
||||
# We log to /tmp so the plugin can read it after the session.
|
||||
# autostart_log starts logging immediately when MangoHud initializes.
|
||||
config_content = """\
|
||||
# DeckyVault MangoHud logging config
|
||||
output_folder=/tmp
|
||||
output_file=deckyvault-mangohud.log
|
||||
autostart_log=0
|
||||
fps
|
||||
frame_timing
|
||||
cpu_power
|
||||
@@ -254,21 +253,20 @@ benchmark_percentiles=97,AVG,1,0.1
|
||||
"""Find the most recent MangoHud log file in /tmp/.
|
||||
MangoHud creates log files with the game name and timestamp."""
|
||||
import glob
|
||||
# Look for any CSV or log files in /tmp that might be MangoHud logs
|
||||
candidates = []
|
||||
for pattern in ["/tmp/*.csv", "/tmp/*.log", "/tmp/MangoHud*"]:
|
||||
# MangoHud log files are typically .csv or have MangoHud in the name
|
||||
for pattern in ["/tmp/*MangoHud*", "/tmp/*.csv", "/tmp/*.log"]:
|
||||
for f in glob.glob(pattern):
|
||||
# Skip our own known file
|
||||
if "deckyvault" in f:
|
||||
candidates.append(f)
|
||||
# Skip directories
|
||||
if os.path.isdir(f):
|
||||
continue
|
||||
# Check if the file starts with a MangoHud header
|
||||
# Check if it looks like a MangoHud log (has fps/frametime header)
|
||||
try:
|
||||
with open(f, 'r') as fh:
|
||||
first_line = fh.readline()
|
||||
if 'MangoHud' in first_line or 'fps' in first_line.lower():
|
||||
first_lines = "".join(fh.readline() for _ in range(5))
|
||||
if 'fps' in first_lines.lower() or 'MangoHud' in first_lines:
|
||||
candidates.append(f)
|
||||
except (IOError, UnicodeDecodeError):
|
||||
except (IOError, UnicodeDecodeError, PermissionError):
|
||||
pass
|
||||
if not candidates:
|
||||
return None
|
||||
@@ -299,8 +297,9 @@ benchmark_percentiles=97,AVG,1,0.1
|
||||
"""RPC: Delete all MangoHud log files in /tmp/ so the next recording starts fresh."""
|
||||
import glob
|
||||
try:
|
||||
for pattern in ["/tmp/*.csv", "/tmp/*.log", "/tmp/MangoHud*"]:
|
||||
for pattern in ["/tmp/*MangoHud*", "/tmp/*.csv", "/tmp/*.log"]:
|
||||
for f in glob.glob(pattern):
|
||||
if os.path.isfile(f):
|
||||
try:
|
||||
os.remove(f)
|
||||
except (IOError, PermissionError):
|
||||
|
||||
@@ -14,8 +14,6 @@ import {
|
||||
readAndParseMangohudLog,
|
||||
clearMangohudLog,
|
||||
writeMangohudConfig,
|
||||
startMangohudLogging,
|
||||
stopMangohudLogging,
|
||||
getHardwareInfo,
|
||||
getOsVersion,
|
||||
getProtonVersion,
|
||||
@@ -72,20 +70,16 @@ function Content() {
|
||||
|
||||
// ── Handle start recording ────────────────────────────────────
|
||||
async function handleStart() {
|
||||
// Write MangoHud config with logging settings
|
||||
// Write MangoHud config with autostart_log so logging begins on game launch
|
||||
await writeMangohudConfig()
|
||||
// Clear any previous log file
|
||||
await clearMangohudLog()
|
||||
// Start MangoHud logging via mangohudctl
|
||||
await startMangohudLogging()
|
||||
startRecording()
|
||||
}
|
||||
|
||||
// ── Handle stop recording: parse log + read system info ────────
|
||||
async function handleStop() {
|
||||
try {
|
||||
// Stop MangoHud logging via mangohudctl
|
||||
await stopMangohudLogging()
|
||||
stopRecording()
|
||||
|
||||
// Parse the MangoHud log
|
||||
|
||||
Reference in New Issue
Block a user