Skip to content

Support messageKey option to match Pino's configurable message key #289

@q0rban

Description

@q0rban

Problem

Pino allows configuring the message key via messageKey (e.g., messageKey: 'message'), but pino-gelf hardcodes data.msg in lib/transformer/standard-gelf.js:

if (typeof data.msg === 'string') {
  payload.short_message = data.msg.substring(0, 65);
  payload.full_message = data.msg;
}

When a user configures Pino with a custom messageKey, the message is serialized under that key instead of msg, so pino-gelf never picks it up. The GELF output ends up with a missing or empty short_message/full_message.

Expected behavior

pino-gelf should support a messageKey option (defaulting to 'msg') and use it when reading the message from log data, similar to how pino-pretty handles this.

Suggestion

Accept a messageKey option and use it in the transformer:

const messageKey = opts.messageKey || 'msg';
if (typeof data[messageKey] === 'string') {
  payload.short_message = data[messageKey].substring(0, 65);
  payload.full_message = data[messageKey];
}

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