Skip to content

fix: include defaultMeta when a profiler finishes - #2648

Open
Yahiro025 wants to merge 1 commit into
winstonjs:masterfrom
Yahiro025:fix/profiler-default-meta
Open

Yahiro025 wants to merge 1 commit into
winstonjs:masterfrom
Yahiro025:fix/profiler-default-meta

Conversation

@Yahiro025

Copy link
Copy Markdown

Problem

profiler.done() drops the logger's defaultMeta. Finishing a timer logs the message and duration, but not the metadata configured on the logger (#2162).

Root cause

Profiler#done builds the info object and calls logger.write() directly. defaultMeta is applied in Logger#log, not in write.

Fix

Merge defaultMeta underneath that info object before write. Fields passed to done(), including level and durationMs, still win.

Tests

test/unit/winston/profiler.test.js checks that service from defaultMeta is present and that an explicit message overrides a default message. That assertion fails on master and passes with this change. The existing profiler tests still pass.

Scope

lib/winston/profiler.js only.

Fixes #2162

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.

[Bug]: default metadata is not added on log message of profiler

1 participant