You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
pino runs the custom destination as the last function in the call chain, so the level and messagekey are not known to pino-lambda by the time pino calls our formatter. The fix is pretty simple, however, by supplying your own custom formatter.
import{LogData,ILogFormatter}from'pino-lambda';classCustomLogFormatterimplementsILogFormatter{format(data: LogData): string{const{
awsRequestId,// your custom message key
customMessageKey,// your custom level label key
status
}=data;// extract parts for message formatconsttime=newDate().toISOString();return`${time}${awsRequestId ? `\t${awsRequestId}` : ''}\t${status.toUpperCase()}\t${msg}\t${JSON.stringify(data)}`;}}constdestination=pinoLambdaDestination({formatter: newCustomLogFormatter(),});constlogger=pino(destination);
https://github.com/pinojs/pino/blob/master/docs/api.md#messagekey-string
Configuring
messageKey
will cause the formatter to fail.Additionally we configure a formatter for
level
which returnsstatus
, to meet Datadog's expectations https://docs.datadoghq.com/logs/log_configuration/attributes_naming_convention/#reserved-attributes.The text was updated successfully, but these errors were encountered: