Skip to content

fix(config): validate and normalize log levels - #51

Merged
webcoderspeed merged 1 commit into
Logixia:mainfrom
Disha-k-gowda:fix-level-validation-29
Oct 23, 2026
Merged

webcoderspeed merged 1 commit into
Logixia:mainfrom
Disha-k-gowda:fix-level-validation-29

Conversation

@Disha-k-gowda

@Disha-k-gowda Disha-k-gowda commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

What and why

Closes #29

This PR fixes log-level validation and normalization in Logixia.

Previously:

  • Uppercase levels such as DEBUG were not handled correctly.
  • Invalid log levels were silently accepted.
  • setLevel('nope') could unexpectedly change the effective logging threshold.

Changes:

  • Normalize uppercase built-in levels while preserving custom-level names.
  • Validate configured, environment, and namespace levels.
  • Warn once per logger for invalid configuration values.
  • Reject invalid setLevel() calls without changing the current level.
  • Add eight regression tests.

Invalid environment overrides now fall through to the next configured level. Maintainer feedback on this behavior is welcome.

How I tested it

  • npx jest src/core/__tests__/level-validation.test.ts --runInBand: 8/8 passed
  • npx jest src/core/__tests__/custom-levels.test.ts --runInBand: 31/31 passed
  • npm run typecheck: passed
  • npm run lint: passed
  • Full Jest suite: 946 passed, 1 failed

The remaining failure is a pre-existing Windows EPERM symlink-permission error in src/cli/__tests__/index.test.ts.

Checklist

  • PR title follows Conventional Commits.
  • Full test suite passes locally (one unrelated Windows-specific failure).
  • Tests added for behavior changes.
  • No public API changes requiring README updates.

AI Assistance Disclosure

I used Claude Code to assist with understanding the codebase, drafting regression tests, proposing implementation changes, and reviewing diffs. I independently reviewed the generated changes, corrected issues found during review, and verified the behavior using local tests, typechecking, and linting. I take responsibility for the final contribution.

@Disha-k-gowda
Disha-k-gowda marked this pull request as ready for review October 18, 2026 21:02
@webcoderspeed

Copy link
Copy Markdown
Contributor

Thanks, this reads well. Upper-case env levels work, unknown levels warn once per source, and setLevel('nope') leaves the threshold alone. I agree with the fall-through for an invalid LOGIXIA_LEVEL: ignoring a typo beats silently switching to it.

Small note: resolveInitialLevel() returns envLevel as written (e.g. DEBUG). It's canonicalised later via _validLevel, so behaviour is right, but returning the canonical value there would be clearer. Not a blocker. I'm waiting for CI, which I just approved to run.

@webcoderspeed
webcoderspeed merged commit 2d0bcde into Logixia:main Oct 23, 2026
11 of 12 checks passed
@github-actions

Copy link
Copy Markdown

🎉 This issue has been resolved in version 1.12.6.
Install it: npm install logixia@1.12.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(config): warn on unknown log levels and accept upper-case LOGIXIA_LEVEL

3 participants