Skip to content

Conversation

@drdaemos
Copy link
Collaborator

@drdaemos drdaemos commented Sep 26, 2025

This PR fixes the issue with logger configuration not resolving to a correct logLevel for non-production environments.

Summary by CodeRabbit

  • Refactor

    • Simplified logger setup by separating configuration creation from instantiation.
    • Standardized configuration return types to reduce ambiguity and improve predictability.
    • Ensures consistent logger initialization across environments; no functional changes expected.
    • Improves maintainability and reduces risk of environment-specific divergence.
  • Tests

    • Updated specs to reflect unified configuration behavior.
    • Removed dev-only scenario; retained coverage for label resolution and redaction.

@drdaemos drdaemos requested a review from kibertoad as a code owner September 26, 2025 18:43
@drdaemos drdaemos added the patch label Sep 26, 2025
@drdaemos drdaemos requested review from a team and CarlosGamero as code owners September 26, 2025 18:43
@coderabbitai
Copy link

coderabbitai bot commented Sep 26, 2025

Walkthrough

Refactors logging resolver functions to consistently return LoggerOptions and separate configuration building from logger instantiation. Introduces and exports resolveLoggerConfiguration. Updates resolveLogger and resolveMonorepoLogger to use configuration builders. Test suite removes dev-environment test, renames a test, and retains remaining validation and redaction tests.

Changes

Cohort / File(s) Summary of edits
Tests
src/logging/loggerConfigResolver.spec.ts
Renamed production configuration test; removed dev-environment test block; kept label resolution and redaction tests unchanged.
Logger resolver implementation
src/logging/loggerConfigResolver.ts
Standardized functions to return LoggerOptions for configuration and Logger only on instantiation. Added exported resolveLoggerConfiguration(appConfig: AppLoggerConfig): LoggerOptions. Updated resolveLogger and resolveMonorepoLogger to build options via configuration functions and instantiate loggers unconditionally. Adjusted resolveMonorepoLoggerConfiguration to return LoggerOptions only.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Caller
  participant Resolver as resolveLogger
  participant Builder as resolveLoggerConfiguration
  participant Logger as Logger.create

  Caller->>Resolver: resolveLogger(appConfig)
  Resolver->>Builder: build LoggerOptions
  Builder-->>Resolver: LoggerOptions
  Resolver->>Logger: instantiate with LoggerOptions
  Logger-->>Caller: Logger
  note over Resolver,Builder: Configuration building separated from instantiation
Loading
sequenceDiagram
  autonumber
  actor Caller
  participant Mono as resolveMonorepoLogger
  participant MonoCfg as resolveMonorepoLoggerConfiguration
  participant Logger as Logger.create

  Caller->>Mono: resolveMonorepoLogger(appConfig)
  Mono->>MonoCfg: build LoggerOptions
  MonoCfg-->>Mono: LoggerOptions
  Mono->>Logger: instantiate with LoggerOptions
  Logger-->>Caller: Logger
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The pull request description does not follow the repository’s required template because it omits the “## Changes” section and the “## Checklist” with labels, documentation updates, and test confirmations. Please update the description to include a “## Changes” heading with a summary of what was modified and a “## Checklist” section verifying that the appropriate label has been applied and that documentation and tests were updated or noted as unnecessary.
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title Check ✅ Passed The title clearly identifies the primary change—correcting logLevel application in development environments—and directly aligns with the modifications to resolveLoggerConfiguration and resolveMonorepoLoggerConfiguration that ensure consistent LoggerOptions for non-production contexts. It is concise, specific, and free of extraneous details, making the pull request’s purpose immediately clear to reviewers.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/dev-logger-level

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


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

@drdaemos drdaemos changed the title Fix logLevel not affection development environments Fix logLevel not being applied in development environments Sep 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants