Skip to content

fix: logger.ts#288

Merged
RambokDev merged 17 commits into
mainfrom
dev
May 17, 2026
Merged

fix: logger.ts#288
RambokDev merged 17 commits into
mainfrom
dev

Conversation

@RambokDev
Copy link
Copy Markdown
Collaborator

@RambokDev RambokDev commented May 17, 2026

Summary by CodeRabbit

  • Refactor
    • Internal logging configuration improved for better environment variable handling. No user-facing changes.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 17, 2026

📝 Walkthrough

Walkthrough

The logger configuration migrates from importing environment variables through @/env.mjs to deriving isProd, defaultLevel, and level directly from process.env.NODE_ENV and process.env.LOG_LEVEL. The logger's public export signature remains unchanged.

Changes

Logger environment sourcing

Layer / File(s) Summary
Direct process.env configuration sourcing
src/lib/logger.ts
Replace env.mjs import with direct process.env lookups for NODE_ENV and LOG_LEVEL; recompute isProd, defaultLevel, and level; update logger options to use explicit level: level property assignment.

Possibly related PRs

  • Portabase/portabase#284: Adds LOG_LEVEL defaults in .env.example, directly providing the environment variable that this PR now reads from process.env.
  • Portabase/portabase#285: Also modifies src/lib/logger.ts environment sourcing; reverses a prior switch to env.mjs by returning to direct process.env access.

Poem

🐰 The logger hops free from env's careful cage,
Now reading the nature from process's page,
No module middleman, just plain and direct—
The log level flows as the environment expects,
Simpler paths make the code more correct!


🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'fix: logger.ts' is vague and doesn't describe what was actually fixed in the logger module. Use a more descriptive title that explains the fix, such as 'fix: use process.env directly in logger instead of importing env' to clarify the actual change.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dev

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/lib/logger.ts`:
- Line 5: The assignment to const level currently force-casts raw input with
(process.env.LOG_LEVEL ?? defaultLevel) as pino.Level which can allow
invalid/empty strings into Pino; change it to validate and normalize
process.env.LOG_LEVEL before using it: read process.env.LOG_LEVEL, if it's a
non-empty string and matches one of the allowed pino.Level values (use the known
set or defaultLevel for validation), set level to that value, otherwise fall
back to defaultLevel; update the symbol 'level' initialization and any helper
(e.g., a small validator function) so no direct as pino.Level cast is used and
only validated, type-safe values are assigned.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: f3f3914b-cb4a-420e-ae54-31afff41226a

📥 Commits

Reviewing files that changed from the base of the PR and between 2d55618 and 9fe0466.

📒 Files selected for processing (1)
  • src/lib/logger.ts
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: build-and-test
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (1)
src/lib/logger.ts (1)

3-4: LGTM!

Also applies to: 24-24

Comment thread src/lib/logger.ts
@RambokDev RambokDev merged commit ab52ef6 into main May 17, 2026
5 checks passed
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.

1 participant