This small package is intended to be used as Opencode plugin.
This plugin handles logging of all supported events.
Events are logged as jsonl to the
<project-root>/logs/opencode/log.jsonlIn your project open (or set) your opencode.json or opencode.jsonc file
and add:
You can customize the log directory, filename, and logging scope using environment variables.
| Variable | Description | Default |
|---|---|---|
OPENCODE_LOGGER_DIR |
The directory where logs are stored. Can be absolute or relative to project root. | logs/opencode |
OPENCODE_LOGGER_FILENAME |
The filename for the log file. | log.jsonl |
OPENCODE_LOGGER_SCOPE |
Comma-separated list of event types to log. Supports wildcards (e.g., session.*). |
* (Log all events) |
You can set them when starting the Opencode client:
OPENCODE_LOGGER_DIR=/tmp/my-logs opencodeOr export them, for example in your ~/.bashrc
export OPENCODE_LOGGER_DIR=/tmp/my-logs
export OPENCODE_LOGGER_FILENAME=custom-name.jsonlYou can filter which events are logged using the OPENCODE_LOGGER_SCOPE environment variable.
It accepts a comma-separated string of event types or patterns.
*(Default): Logs all events.session.*: Logs all events starting withsession.(e.g.,session.created,session.updated).command.executed,file.edited: Logs only these specific events.
Example:
export OPENCODE_LOGGER_SCOPE="session.*,command.executed"
{ "$schema": "https://opencode.ai/config.json", "plugin": ["opencode-logger"] }