Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Winston logform library does not have a unified way to return formatted message #125

Open
@losalex

Description

@losalex

The code sampleconst { level, message, ...meta } = info; describedhere does not always returns message consistently and may vary depending if format object was provided towinston.createLogger() or not. It appears thatinfo parameter could also have aninfo[Symbol.for('message')] in addition toinfo.message field and those values are not the same:

  1. In case when no formatting is provided towinston.createLogger() constructor, the correct message indeed returned byinfo.message.
  2. When formatting is provided towinston.createLogger() constructor, the correct message will be ininfo[MESSAGE] field, whileinfo.message contains non-formatted version of the message.

Given a fact that we don't have a way to see if formatting was provided forwinston.createLogger() constructor or not, we cannot provide a deterministic approach to fetch correct message (e.g. we cannot count oninfo[MESSAGE] nor oninfo.message fields to determine where is a "right" message is).

The code which can be used to test the issue is:

constlogger=winston.createLogger({level:LOG_LEVEL,format:winston.format.combine(winston.format.timestamp({format:'YYYY-MM-DD HH:mm:ss,SSS'}),winston.format.printf(info=>`${info.timestamp} |${info.level.toUpperCase()}| my-service ->${info.message}`)),transports:[// Add custom transport here to intercept the info for debugging purposes//new SomeTransportLogging(),newwinston.transports.Console()]});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2026 Movatter.jp