Skip to content

fix(pad-levels): guard against undefined padding for unknown levels - #350

Merged
DABH merged 1 commit into
winstonjs:masterfrom
mixelburg:fix/pad-levels-unknown-level
Jun 13, 2026
Merged

fix(pad-levels): guard against undefined padding for unknown levels#350
DABH merged 1 commit into
winstonjs:masterfrom
mixelburg:fix/pad-levels-unknown-level

Conversation

@mixelburg

Copy link
Copy Markdown
Contributor

When a logger uses custom levels (e.g. `config.syslog.levels`) but the `padLevels` format is initialized with a different level set, `this.paddings[info[LEVEL]]` is `undefined`. This gets coerced to the string `"undefined"` and prepended to every log message.

Defensive fix: default to `""` when a level is missing from the padding map.

Fixes the behavior reported in winstonjs/winston#2477 where using `format.cli()` with syslog levels produces output like emerg:undefinedHello World!.

@mixelburg

Copy link
Copy Markdown
Contributor Author

\ud83d\udd27 Auto-fix: Rebased onto latest to resolve the TypeScript 6.0 deprecation CI failure.

@mixelburg
mixelburg force-pushed the fix/pad-levels-unknown-level branch from 865151a to 4870971 Compare June 13, 2026 00:15
@DABH
DABH merged commit 7a35d25 into winstonjs:master Jun 13, 2026
3 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.

2 participants