A session runs a line
↓→
Command logs
in memory or on disk
↓→
Read them with
history/.bash_historymirage workspace logsws.history()Reading logs
mirage shell --no-record runs a line without logging it.
Example
Run three lines in a workspace that mounts a RAM folder at/data.
mirage workspace logs -w demo lists the lines newest first. This is the entry
for the second line. mounts lists the read that wc made, and cwd is
where the line started.
cat has its own entry with "exit_code": 1 and the error in
stderr.
mirage workspace logs -w demo --jsonl and ws.history(vfs=True) return the
same line as three records, linked by parent:
Log entries
Mirage splits input into entries the same way bash does.
A
set -e failure stops a line the same way exit does. If a
post_execute policy checks a line, Mirage writes
the entry after the policy answers. Output that the policy drops never
reaches the logs.
Log storage
A workspace you build in code keeps its logs in memory. A workspace the server builds keeps them on disk under~/.mirage/state. Logs grow with every
command, so store.observer moves them without moving the rest of the
workspace state.
Redis does not hold logs. With
store.type: redis, Mirage writes the logs to
disk under the store’s root, unless store.observer names another backend.
To collect logs from several machines in one place, export them as
traces.
This config keeps the rest of the workspace state on Redis and the logs on
local disk.
- YAML
- Python
- TypeScript
Logs and traces
Mirage keeps command logs itself and serves them back to you, to the agent and to policies. Traces carry the same activity out to an OpenTelemetry backend, and Mirage keeps no copy of them.
Use command logs when the agent, a policy or you need to look back at what a
workspace ran. Use traces to watch many machines in one place, with your
tool’s search, retention and alerts.
Restarts
Each log belongs to a session. A rebuilt workspace shows a session’s logs only after it has that session again. To keep logs across a restart, do one of these.- Keep the sessions on a store that survives a restart.
- Give the default session a fixed id with
default_session_id.