fix: move log dir from /tmp/playwriter to ~/.playwriter (fixes #44)

This commit is contained in:
Tommy D. Rossi
2026-02-06 10:44:28 +01:00
parent 7f3fddb2af
commit d6adb460d5
7 changed files with 24 additions and 13 deletions
+1 -1
View File
@@ -271,7 +271,7 @@ you can find the logfile for playwriter executing `playwriter logfile`. read tha
`playwriter logfile` also logs a jsonl file with all CDP commands and events being sent between extension, cli, mcp and relay. the cdp log is a jsonl file (one json object per line). you can use jq to process and read it efficiently. for example, list direction + method:
```bash
jq -r '.direction + "\t" + (.message.method // "response")' /tmp/playwriter/cdp.jsonl | uniq -c
jq -r '.direction + "\t" + (.message.method // "response")' ~/.playwriter/cdp.jsonl | uniq -c
```
## testing iframe behaviour with snapshots and out of process frames
+1 -1
View File
@@ -269,7 +269,7 @@ you can find the logfile for playwriter executing `playwriter logfile`. read tha
`playwriter logfile` also logs a jsonl file with all CDP commands and events being sent between extension, cli, mcp and relay. the cdp log is a jsonl file (one json object per line). you can use jq to process and read it efficiently. for example, list direction + method:
```bash
jq -r '.direction + "\t" + (.message.method // "response")' /tmp/playwriter/cdp.jsonl | uniq -c
jq -r '.direction + "\t" + (.message.method // "response")' ~/.playwriter/cdp.jsonl | uniq -c
```
## testing iframe behaviour with snapshots and out of process frames
+2 -2
View File
@@ -244,7 +244,7 @@ View relay server logs to debug issues:
```bash
playwriter logfile # prints the log file path
# typically: /tmp/playwriter/relay-server.log (Linux/macOS)
# typically: ~/.playwriter/relay-server.log
```
The relay log contains extension, MCP and WebSocket server logs. A separate CDP JSONL log is also created alongside it (see `playwriter logfile`). Both are recreated on each server start.
@@ -252,7 +252,7 @@ The relay log contains extension, MCP and WebSocket server logs. A separate CDP
Example: summarize CDP traffic counts by direction + method:
```bash
jq -r '.direction + "\t" + (.message.method // "response")' /tmp/playwriter/cdp.jsonl | uniq -c
jq -r '.direction + "\t" + (.message.method // "response")' ~/.playwriter/cdp.jsonl | uniq -c
```
## Known Issues
+6
View File
@@ -1,5 +1,11 @@
# Changelog
## 0.0.57
### Bug Fixes
- **Fix log dir permissions on shared machines**: Move default log directory from `/tmp/playwriter` to `~/.playwriter` so each OS user gets their own directory. Fixes startup crash when `/tmp/playwriter` is owned by another user (#44).
## 0.0.56
### Bug Fixes
+3 -3
View File
@@ -96,11 +96,11 @@ EOF
### Debugging playwriter issues
If some internal critical error happens you can read the relay server logs to understand the issue. The log file is located in the system temp directory:
If some internal critical error happens you can read the relay server logs to understand the issue. The log file is located in the user home directory:
```bash
playwriter logfile # prints the log file path
# typically: /tmp/playwriter/relay-server.log (Linux/macOS) or %TEMP%\playwriter\relay-server.log (Windows)
# typically: ~/.playwriter/relay-server.log
```
The relay log contains logs from the extension, MCP and WS server. A separate CDP JSONL log is created alongside it (see `playwriter logfile`) with all CDP commands/responses and events, with long strings truncated. Both files are recreated every time the server starts. For debugging internal playwriter errors, read these files with grep/rg to find relevant lines.
@@ -108,7 +108,7 @@ The relay log contains logs from the extension, MCP and WS server. A separate CD
Example: summarize CDP traffic counts by direction + method:
```bash
jq -r '.direction + "\t" + (.message.method // "response")' /tmp/playwriter/cdp.jsonl | uniq -c
jq -r '.direction + "\t" + (.message.method // "response")' ~/.playwriter/cdp.jsonl | uniq -c
```
If you find a bug, you can create a gh issue using `gh issue create -R remorses/playwriter --title title --body body`. Ask for user confirmation before doing this.
+3 -2
View File
@@ -33,8 +33,9 @@ export function getCdpUrl({
return `ws://${host}:${port}/cdp/${id}${suffix}`
}
const LOG_BASE_DIR = os.platform() === 'win32' ? os.tmpdir() : '/tmp'
export const LOG_FILE_PATH = process.env.PLAYWRITER_LOG_FILE_PATH || path.join(LOG_BASE_DIR, 'playwriter', 'relay-server.log')
// Use ~/.playwriter for logs so each OS user gets their own dir (avoids permission errors on shared machines, see #44)
const LOG_BASE_DIR = path.join(os.homedir(), '.playwriter')
export const LOG_FILE_PATH = process.env.PLAYWRITER_LOG_FILE_PATH || path.join(LOG_BASE_DIR, 'relay-server.log')
export const LOG_CDP_FILE_PATH = process.env.PLAYWRITER_CDP_LOG_FILE_PATH || path.join(path.dirname(LOG_FILE_PATH), 'cdp.jsonl')
const packageJsonPath = path.join(path.dirname(fileURLToPath(import.meta.url)), '..', 'package.json')
+8 -4
View File
@@ -70,6 +70,10 @@ playwriter -s 1 -e "await page.screenshot({ path: 'screenshot.png', scale: 'css'
# Get accessibility snapshot
playwriter -s 1 -e "await accessibilitySnapshot({ page })"
# Get accessibility snapshot for a specific iframe
const frame = await page.locator('iframe').contentFrame()
await accessibilitySnapshot({ frame })
```
**Multiline code:**
@@ -92,11 +96,11 @@ EOF
### Debugging playwriter issues
If some internal critical error happens you can read the relay server logs to understand the issue. The log file is located in the system temp directory:
If some internal critical error happens you can read the relay server logs to understand the issue. The log file is located in the user home directory:
```bash
playwriter logfile # prints the log file path
# typically: /tmp/playwriter/relay-server.log (Linux/macOS) or %TEMP%\playwriter\relay-server.log (Windows)
# typically: ~/.playwriter/relay-server.log
```
The relay log contains logs from the extension, MCP and WS server. A separate CDP JSONL log is created alongside it (see `playwriter logfile`) with all CDP commands/responses and events, with long strings truncated. Both files are recreated every time the server starts. For debugging internal playwriter errors, read these files with grep/rg to find relevant lines.
@@ -104,7 +108,7 @@ The relay log contains logs from the extension, MCP and WS server. A separate CD
Example: summarize CDP traffic counts by direction + method:
```bash
jq -r '.direction + "\t" + (.message.method // "response")' /tmp/playwriter/cdp.jsonl | uniq -c
jq -r '.direction + "\t" + (.message.method // "response")' ~/.playwriter/cdp.jsonl | uniq -c
```
If you find a bug, you can create a gh issue using `gh issue create -R remorses/playwriter --title title --body body`. Ask for user confirmation before doing this.
@@ -113,7 +117,7 @@ If you find a bug, you can create a gh issue using `gh issue create -R remorses/
# playwriter best practices
Control user's Chrome browser via playwright code snippets. Prefer single-line code with semicolons between statements. If you get "extension is not connected" or "no browser tabs have Playwriter enabled" error, tell user to click the playwriter extension icon on the tab they want to control.
Control user's Chrome browser via playwright code snippets. Prefer single-line code with semicolons between statements. Use playwriter immediately without waiting for user actions; only if you get "extension is not connected" or "no browser tabs have Playwriter enabled" should you ask the user to click the playwriter extension icon on the target tab.
You can collaborate with the user - they can help with captchas, difficult elements, or reproducing bugs.