-
-
Notifications
You must be signed in to change notification settings - Fork 2
feat(commands): add sentry log list command #160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
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.
Semver Impact of This PR🟡 Minor (new features) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨
Bug Fixes 🐛
🤖 This preview updates automatically when you update the PR. |
Codecov Results 📊❌ Patch coverage is 68.22%. Project has 1992 uncovered lines. Files with missing lines (28)
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 |
…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.
There was a problem hiding this 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.
Summary
Adds
sentry log listcommand to list and stream logs from Sentry projects. Supports real-time streaming with--followflag using efficient timestamp-based polling.Usage
Changes
src/commands/log/with list commandlistLogs()withafterTimestampsupport for follow modeissue list(parseOrgProjectArg, writeFooter, etc.)Test Plan
bun test test/lib/formatters/log.test.ts- formatter unit tests