fix(logger)!: default to info when DEPLOYMENT_ENV is unset - #14
Closed
Henry Zhang (caezium) wants to merge 3 commits into
Closed
Conversation
An absent DEPLOYMENT_ENV was treated as "development" and defaulted the log level to debug, so any SDK consumer embedding this package (e.g. via spectrum-ts) that doesn't set DEPLOYMENT_ENV got a debug firehose on import. Default to info unless DEPLOYMENT_ENV is explicitly "development"; LOG_LEVEL and setLogLevel() still override. Updates docstrings + adds a regression test. DX-REPORT photon-hq#10.
The defaultLevel() change — an absent DEPLOYMENT_ENV now defaults to `info`, and only an explicit `development` opts into `debug` — shipped in code and in the logger.ts / setup.ts docstrings, but four user-facing docs still described the old `unset => debug` behavior. That directly contradicts the shipped default and would tell an SDK consumer the debug firehose is on when it is not — the exact confusion DX photon-hq#10 removes. Update README.md, configuration.mdx, logging.mdx, and reference/environment.mdx to match. The `deployment.environment` resource attribute still defaults to `development` when unset (setup.ts) — that is a telemetry label, not a verbosity signal, and is intentionally left unchanged.
Document that only the deployment.environment resource attribute falls back to development, while log-level resolution uses the raw environment value. Behavior change: an unset DEPLOYMENT_ENV now selects info. Consumers upgrading from v3.2.0 can set LOG_LEVEL=debug to preserve the previous verbosity. Add public-API coverage for setupOtel log-level precedence.
Henry Zhang (caezium)
requested a review
from Ryan Zhu (underthestars-zhy)
as a code owner
July 21, 2026 21:25
📝 WalkthroughWalkthroughThe logger now defaults to ChangesDeployment-aware log-level defaults
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
infowhenDEPLOYMENT_ENVis unset.debugby default only for explicitDEPLOYMENT_ENV=development.LOG_LEVEL→ programmatic override → environment-derived default.deployment.environmentresource fallback does not control logging.setupOtel({ logLevel })precedence.LOG_LEVEL=debugcompatibility path.Why
@photon-ai/otelpreviously treated an absentDEPLOYMENT_ENVas development. Unset is the normal case for embedding SDK consumers such as Spectrum, so ordinary SDK use could emit debug-level console noise without an explicit debug opt-in.Spectrum embeds this package and uses its structured logger even when telemetry export is disabled. The
telemetry: trueoption controls OTLP setup; it does not control whether Spectrum emits console logs.Breaking change
Consumers relying on unset
DEPLOYMENT_ENVproducing debug output must now set:Spectrum consumers can alternatively configure:
The OpenTelemetry
deployment.environmentresource attribute still falls back todevelopment; only the logger threshold changes.If this ships on the OTel 4.x line, Spectrum must bump its current
^3.1.0dependency before normal Spectrum projects receive the change.Validation
bun run test— 98/98 tests passednode ./node_modules/vitest/vitest.mjs run— 98/98 tests passedbun run buildbun x ultracite checkgit diff --check main...HEADNeed help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.Note
Medium Risk
Behavior change for embedders and anyone depending on implicit debug logging without setting
LOG_LEVELorDEPLOYMENT_ENV=development; telemetry resource attributes are unchanged.Overview
Breaking change: default log verbosity no longer treats an unset
DEPLOYMENT_ENVlikedevelopment.defaultLevel()inlogger.tsnow usesdebugonly whenDEPLOYMENT_ENVis exactlydevelopment; otherwise it usesinfo, including when the variable is missing.setupOtel()still setsdeployment.environmenttodevelopmentwhen unset—only the logger threshold changes.Precedence is unchanged:
LOG_LEVEL→setupOtel({ logLevel })/setLogLevel()→ env-derived default. Docs (README, configuration, logging, API, environment) describe the split and note that v3.2.0 users who relied on unset env fordebugshould setLOG_LEVEL=debug.Tests add coverage for unset
DEPLOYMENT_ENV→infoand forlogLevelvsLOG_LEVELprecedence viasetupOtel.Reviewed by Cursor Bugbot for commit f21b618. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by CodeRabbit
Bug Fixes
debugis now used only whenDEPLOYMENT_ENV=development; otherwise, the default isinfo.LOG_LEVELsettings and programmatic overrides.developmentindependently.Documentation