diff --git a/docs/src/content/docs/commands/index.md b/docs/src/content/docs/commands/index.md index 45aae5d5..14576cdd 100644 --- a/docs/src/content/docs/commands/index.md +++ b/docs/src/content/docs/commands/index.md @@ -15,6 +15,7 @@ The Sentry CLI provides commands for interacting with various Sentry resources. | [`project`](./project/) | Project operations | | [`issue`](./issue/) | Issue tracking | | [`event`](./event/) | Event inspection | +| [`log`](./log/) | Log viewing and streaming | | [`api`](./api/) | Direct API access | ## Global Options diff --git a/docs/src/content/docs/commands/log.md b/docs/src/content/docs/commands/log.md new file mode 100644 index 00000000..c19d60e8 --- /dev/null +++ b/docs/src/content/docs/commands/log.md @@ -0,0 +1,103 @@ +--- +title: log +description: Log commands for the Sentry CLI +--- + +View and stream logs from Sentry projects. + +## Commands + +### `sentry log list` + +List and stream logs from a project. + +```bash +# Auto-detect from DSN or config +sentry log list + +# Explicit org and project +sentry log list / + +# Search for project across all accessible orgs +sentry log list +``` + +**Arguments:** + +| Argument | Description | +|----------|-------------| +| `/` | Explicit organization and project (e.g., `my-org/backend`) | +| `` | Search for project by name across all accessible organizations | + +**Options:** + +| Option | Description | +|--------|-------------| +| `-n, --limit ` | Number of log entries to show (1-1000, default: 100) | +| `-q, --query ` | Filter query (Sentry search syntax) | +| `-f, --follow [interval]` | Stream logs in real-time (optional: poll interval in seconds, default: 2) | +| `--json` | Output as JSON | + +**Examples:** + +```bash +# List last 100 logs (default) +sentry log list +``` + +``` +TIMESTAMP LEVEL MESSAGE +2024-01-20 14:22:01 info User login successful +2024-01-20 14:22:03 debug Processing request for /api/users +2024-01-20 14:22:05 error Database connection timeout +2024-01-20 14:22:06 warn Retry attempt 1 of 3 + +Showing 4 logs. +``` + +**Stream logs in real-time:** + +```bash +# Stream with default 2-second poll interval +sentry log list -f + +# Stream with custom 5-second poll interval +sentry log list -f 5 +``` + +**Filter logs:** + +```bash +# Show only error logs +sentry log list -q 'level:error' + +# Filter by message content +sentry log list -q 'database' +``` + +**Limit results:** + +```bash +# Show last 50 logs +sentry log list --limit 50 + +# Show last 500 logs +sentry log list -n 500 +``` + +**Combine options:** + +```bash +# Stream error logs from a specific project +sentry log list my-org/backend -f -q 'level:error' +``` + +## JSON Output + +Use `--json` for machine-readable output: + +```bash +sentry log list --json | jq '.[] | select(.level == "error")' +``` + +In streaming mode with `--json`, each log entry is output as a separate JSON object (newline-delimited JSON), making it suitable for piping to other tools. diff --git a/plugins/sentry-cli/skills/sentry-cli/SKILL.md b/plugins/sentry-cli/skills/sentry-cli/SKILL.md index bd285174..61c713d9 100644 --- a/plugins/sentry-cli/skills/sentry-cli/SKILL.md +++ b/plugins/sentry-cli/skills/sentry-cli/SKILL.md @@ -424,6 +424,45 @@ List logs from a project - `-f, --follow - Stream logs (optionally specify poll interval in seconds)` - `--json - Output as JSON` +**Examples:** + +```bash +# Auto-detect from DSN or config +sentry log list + +# Explicit org and project +sentry log list / + +# Search for project across all accessible orgs +sentry log list + +# List last 100 logs (default) +sentry log list + +# Stream with default 2-second poll interval +sentry log list -f + +# Stream with custom 5-second poll interval +sentry log list -f 5 + +# Show only error logs +sentry log list -q 'level:error' + +# Filter by message content +sentry log list -q 'database' + +# Show last 50 logs +sentry log list --limit 50 + +# Show last 500 logs +sentry log list -n 500 + +# Stream error logs from a specific project +sentry log list my-org/backend -f -q 'level:error' + +sentry log list --json | jq '.[] | select(.level == "error")' +``` + ### Issues List issues in a project