Skip to content

Conversation

@betegon
Copy link
Member

@betegon betegon commented Feb 3, 2026

Summary

Adds sentry log list command to list and stream logs from Sentry projects. Supports real-time streaming with --follow flag using efficient timestamp-based polling.

Usage

sentry log list                    # auto-detect from DSN
sentry log list <org>/<project>    # explicit target
sentry log list <project>          # find project across orgs
sentry log list -f                 # stream in real-time
sentry log list --tail 50 -q 'level:error'

Changes

  • New src/commands/log/ with list command
  • Log formatters with severity coloring and timestamp formatting
  • API client method listLogs() with afterTimestamp support for follow mode
  • Follows existing patterns from issue list (parseOrgProjectArg, writeFooter, etc.)

Test Plan

  • bun test test/lib/formatters/log.test.ts - formatter unit tests
  • Manual testing with real Sentry project using all target modes

Add new command to list and stream logs from Sentry projects:

- Auto-detects org/project from DSN or accepts explicit target
- Supports --follow flag for real-time streaming
- Uses timestamp-based filtering for efficient follow mode
- Includes --tail, --query, --json flags

The log list command follows existing patterns from issue list,
using parseOrgProjectArg for flexible target specification.
@github-actions
Copy link

github-actions bot commented Feb 3, 2026

Semver Impact of This PR

🟡 Minor (new features)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

  • (commands) Add sentry log list command by betegon in #160

Bug Fixes 🐛

  • Added nullable in substatus's zod validation by MathurAditya724 in #157

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link

github-actions bot commented Feb 3, 2026

Codecov Results 📊

❌ Patch coverage is 68.22%. Project has 1992 uncovered lines.
✅ Project coverage is 69.68%. Comparing base (base) to head (head).

Files with missing lines (28)
File Patch % Lines
human.ts 31.97% ⚠️ 681 Missing
resolve-target.ts 26.39% ⚠️ 251 Missing
oauth.ts 25.10% ⚠️ 194 Missing
api-client.ts 69.78% ⚠️ 175 Missing
upgrade.ts 39.76% ⚠️ 153 Missing
resolver.ts 3.23% ⚠️ 120 Missing
errors.ts 5.94% ⚠️ 95 Missing
migration.ts 47.44% ⚠️ 82 Missing
api.ts 89.80% ⚠️ 47 Missing
seer.ts 75.54% ⚠️ 45 Missing
seer.ts 79.87% ⚠️ 30 Missing
preload.ts 39.02% ⚠️ 25 Missing
version-check.ts 76.00% ⚠️ 18 Missing
detector.ts 87.79% ⚠️ 16 Missing
schema.ts 64.10% ⚠️ 14 Missing
auth.ts 94.78% ⚠️ 7 Missing
feedback.ts 84.21% ⚠️ 6 Missing
upgrade.ts 93.83% ⚠️ 5 Missing
utils.ts 97.60% ⚠️ 4 Missing
index.ts 95.06% ⚠️ 4 Missing
colors.ts 91.84% ⚠️ 4 Missing
telemetry.ts 97.20% ⚠️ 4 Missing
env-file.ts 97.17% ⚠️ 3 Missing
sentry-urls.ts 88.00% ⚠️ 3 Missing
alias.ts 98.56% ⚠️ 2 Missing
project-aliases.ts 97.40% ⚠️ 2 Missing
java.ts 97.22% ⚠️ 1 Missing
parser.ts 98.63% ⚠️ 1 Missing
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    69.68%    69.68%        —%
==========================================
  Files           56        57        +1
  Lines         6462      6570      +108
  Branches         0         0         —
==========================================
+ Hits          4503      4578       +75
- Misses        1959      1992       +33
- Partials         0         0         —

Generated by Codecov Action

@betegon betegon marked this pull request as ready for review February 3, 2026 14:58
…fter write

- Reverse logs before printing in follow mode for tail -f style (oldest first)
- Move timestamp update after successful writeLogs() to prevent silent log loss
Both single fetch and follow mode now display logs consistently:
oldest at top, newest at bottom (like tail command)
Follow mode now only shows logs from the last minute before streaming,
instead of pulling from 90 days of history. This matches the expected
tail -f behavior where you see recent logs then stream new ones.
Since follow mode runs indefinitely and never reaches the normal exit
where notifications are shown, display the update notification right
after 'Press Ctrl+C to stop' and before streaming begins.
Track headerPrinted state to ensure the column header (TIMESTAMP LEVEL
MESSAGE) is shown before the first logs, whether they come from the
initial fetch or from a subsequent poll in follow mode.
… mode

When follow mode starts with an empty initial fetch (no logs in the last
minute), lastTimestamp was set to 0. Since 0 is falsy in JavaScript, the
timestamp filter in api-client.ts was omitted, causing the first poll to
fetch ALL logs from the last 10 minutes instead of only new ones.

Fix: Use Date.now() * 1_000_000 (nanoseconds) as the fallback, so polling
starts from the current time when there are no initial logs.
Previously, errors during follow mode polling were:
1. Not reported to Sentry (swallowed locally)
2. Silently suppressed in JSON mode

Now errors are always:
1. Captured to Sentry for visibility into polling failures
2. Written to stderr (which doesn't interfere with JSON output on stdout)

This follows the established pattern used in version-check.ts and auth/login.ts
for local catch blocks that continue operation.
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

@betegon betegon requested a review from BYK February 3, 2026 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants