feat(logs): Improve logs streaming and backlog delivery; add CLI filters and ndjson output
This commit is contained in:
34
readme.md
34
readme.md
@@ -177,11 +177,15 @@ Watch: disabled
|
||||
|
||||
#### `tspm logs <id|id:N|name:LABEL> [options]`
|
||||
|
||||
View process logs (stdout and stderr combined).
|
||||
View and stream process logs (stdout, stderr, and system messages).
|
||||
|
||||
**Options:**
|
||||
- `--lines <n>` - Number of lines to display (default: 50)
|
||||
- `--follow` - Stream logs in real-time (like `tail -f`)
|
||||
- `--lines <n>` Number of lines to show (default: 50)
|
||||
- `--since <dur>` Only show logs since duration (e.g., `10m`, `2h`, `1d`; units: `ms|s|m|h|d`)
|
||||
- `--stderr-only` Only show stderr logs
|
||||
- `--stdout-only` Only show stdout logs
|
||||
- `--ndjson` Output each log as JSON line (timestamp in ms)
|
||||
- `--follow` Stream logs in real-time (like `tail -f`)
|
||||
|
||||
```bash
|
||||
# View last 50 lines
|
||||
@@ -190,10 +194,20 @@ tspm logs name:my-server
|
||||
# View last 100 lines
|
||||
tspm logs name:my-server --lines 100
|
||||
|
||||
# Follow logs in real-time
|
||||
# Only stderr for the last 10 minutes (as NDJSON)
|
||||
tspm logs name:my-server --since 10m --stderr-only --ndjson
|
||||
|
||||
# Follow logs in real time (prints recent lines, then streams backlog incrementally and live logs)
|
||||
tspm logs name:my-server --follow
|
||||
|
||||
# Follow only stdout since 2h ago
|
||||
tspm logs name:my-server --follow --since 2h --stdout-only
|
||||
```
|
||||
|
||||
Notes:
|
||||
- Follow mode prints a small recent backlog, then streams older entries incrementally (to avoid large payloads) and continues with live logs.
|
||||
- Log sequences are restart-aware; TSPM detects run changes and keeps output consistent across restarts.
|
||||
|
||||
### Batch Operations
|
||||
|
||||
#### `tspm start-all`
|
||||
@@ -285,6 +299,18 @@ Processes: 5
|
||||
Socket: /home/user/.tspm/tspm.sock
|
||||
```
|
||||
|
||||
#### Version check and service refresh
|
||||
|
||||
Check CLI vs daemon versions and refresh the systemd service if they differ:
|
||||
|
||||
```bash
|
||||
tspm -v
|
||||
# tspm CLI: 5.x.y
|
||||
# Daemon: running v5.x.z (pid 1234)
|
||||
# Version mismatch detected → optionally refresh the systemd service (equivalent to `tspm disable && tspm enable`).
|
||||
```
|
||||
This is helpful after upgrades where the system service still references an older CLI path.
|
||||
|
||||
### System Service Management
|
||||
|
||||
Run TSPM as a system service (systemd) for production deployments.
|
||||
|
Reference in New Issue
Block a user