Skip to content

feat(cli-logger): Publish the CLI logger as @sentry/cli-logger - #1773

Open
sentry-junior[bot] wants to merge 1 commit into
mainfrom
feat/cli-logger-package
Open

sentry-junior[bot] wants to merge 1 commit into
mainfrom
feat/cli-logger-package

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

Fixes #1772.

Moves the logger from #1771 out of packages/cli/src/lib/logger.ts into a new packages/cli-logger workspace package, published to npm as @sentry/cli-logger.

Package API

  • createLogger({ level, env, formatTime, prompt }) returns a root logger. Its withTag() loggers share the root's level and reporter list, as before. Each root has its own state, so the module-level singleton is gone from the package.
  • Exports parseLogLevel, LOG_LEVEL_NAMES, formatLocalTime, and the LogObject/LogReporter/Prompt types. Records still have consola's shape, so Sentry.createConsolaReporter() works with addReporter().
  • @sentry/cli-logger/prompt exports clackPrompt. @clack/prompts is an optional peer dependency, and the main entry never references it.

How the CLI-local pieces were split out

  • getEnv() → the env option, read on each log call. The CLI passes getEnv, so library mode's isolated env still controls colors and layout. A CLI test covers this with withEnv.
  • formatLogTime() → moved into the package as the default formatLocalTime, since only the logger used it. Its tests moved with it.
  • SENTRY_CLI_COMPLETION_BUILD → stays in the CLI. The CLI's askUser keeps the define guard and lazy-imports @sentry/cli-logger/prompt, so dist/complete.cjs still contains no @clack/prompts. The package itself has no build-time globals.

packages/cli/src/lib/logger.ts keeps every export it had, so its ~170 importers and the vi.mock calls in tests don't change.

Packaging and release

  • In the workspace, exports point at src/*.ts, like toolkit-core, so the CLI's esbuild bundle, vitest, and tsc need no build step. publishConfig.exports points the packed tarball at the tsdown ESM/CJS dist/, with .d.ts/.d.cts types.
  • New cli-logger craft workspace (tag prefix cli-logger@, release branch release/cli-logger/*) and a cli-logger option in the Release workflow. Post-merge jobs now also pack the tarball into the commit's artifact.
  • New CLI Logger Package workflow: it packs the package, installs it into a clean npm project, typechecks ESM and CJS consumers, and runs both.

Decisions to confirm

  • Name: @sentry/cli-logger. It's free on npm. I avoided @sentry/logger because it reads like the SDK's logger.
  • License: FSL-1.1-Apache-2.0, same as the CLI and the repo. Say so if this should be a more permissive license for a reusable library.
  • Version starts at 0.1.0. The first npm publish happens when someone runs Release with cli-logger.

via @BYK.

--

View Session in Sentry

Move the logger from packages/cli/src/lib/logger.ts into a new
packages/cli-logger workspace package, published to npm as
@sentry/cli-logger. createLogger() takes the CLI-specific pieces as
options: env (the CLI passes getEnv for library mode) and prompt (the
CLI keeps its completion-build guard around clackPrompt). formatLogTime
moves into the package as the default formatLocalTime.

The CLI's logger.ts keeps its exports, so callers and test mocks do not
change. Releases go through the Release workflow's new cli-logger
product.

Fixes #1772

Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
@vercel

vercel Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
sentry-local Ready Ready Preview Oct 31, 2026 3:41pm UTC

Request Review

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

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.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 3b25814. Configure here.

Comment thread .craft.yml
end
packages/cli-logger:
changelog:
policy: auto

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Craft auto changelog lacks CHANGELOG

Medium Severity

The new cli-logger Craft workspace sets changelog.policy to auto, but packages/cli-logger has no CHANGELOG.md. The CLI workspace that uses the same policy keeps that file next to the package. Craft’s prepare step reads and updates it, so the first cli-logger release can fail before npm publish.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 3b25814. Configure here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Checked this against Craft: with changelog.policy: auto, prepareChangelog creates the missing file instead of failing (src/commands/prepare.ts: if (!existsSync(relativePath)) { if (changelogPolicy === ChangelogPolicy.Auto) { ... safeFs.writeFile(relativePath, "# Changelog\n") } ...}). That code is in the v3 tag release.yml uses. For a workspace, the default path is <workspace>/CHANGELOG.md (getDefaultChangelogFilePath in src/config.ts), so the first cli-logger release creates packages/cli-logger/CHANGELOG.md and commits it on the release branch. Leaving the config as is.

This branch was successfully deployed

1 active deployment
Preview — 3b25814b Deployed Oct 31, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Publish the CLI logger as a standalone package

1 participant