Skip to content

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

Closed

Description

@webcoderspeed

Context

A small piece of #7 (config validation).

resolveInitialLevel (src/core/logitron-logger.ts line 131) takes process.env.LOGIXIA_LEVEL or levelOptions.level as-is. The numeric lookup in _buildPerfCaches (around line 336) then does this._levelValues.get(effectiveLevel) ?? 2. So:

  • LOGIXIA_LEVEL=DEBUG (upper case) silently becomes info, because the level map keys are lower case
  • a typo like levelOptions: { level: 'warning' } silently becomes info
  • setLevel('nope') (line 510) keeps the old threshold but stores 'nope', so getLevel() returns a level that isn't in effect

What to do

  • Normalise the resolved level to lower case in resolveInitialLevel and in setLevel
  • When the level isn't in _levelValues (built-ins plus custom levels), call internalWarn once per logger with the bad value and the list of valid levels, then fall back to info as today
  • In setLevel, refuse unknown levels: warn and keep the current level, so getLevel() stays truthful
  • Tests in src/core/__tests__/level-validation.test.ts:
    • LOGIXIA_LEVEL=DEBUG enables debug
    • unknown level warns once and logs at info
    • a custom level such as kafka is accepted
    • setLevel('nope') warns and getLevel() is unchanged

Acceptance criteria

  • npx jest src/core/__tests__/level-validation.test.ts passes, and the full npx jest still passes
  • npm run typecheck && npm run lint pass

Hints

  • internalWarn is in src/utils/internal-log.ts. Tests can silence or capture it, see src/utils/__tests__/internal-log.test.ts.
  • src/core/__tests__/custom-levels.test.ts shows how custom levels are configured.

Activity

  1. github-actions commented on Oct 24, 2026

    @github-actions

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

  2. Disha-k-gowda commented on Oct 24, 2026

    @Disha-k-gowda
    Contributor

    I completed the fix for this issue in PR #51, which has now been merged.

    The changes include log-level validation, normalization, and regression tests.

    I didn't post an initial claim before starting the work, so I'm documenting the completed contribution here for transparency. Thank you for reviewing and merging the fix!

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions