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);
Activity
carbonrobot commentedon Nov 7, 2023
pinoruns the custom destination as the last function in the call chain, so the level and messagekey are not known topino-lambdaby the timepinocalls our formatter. The fix is pretty simple, however, by supplying your own custom formatter.alexander-williamson commentedon Dec 19, 2025
We also ran into something similar - we would like to use the library but have our
messageKeygo frommsgtomessagePS thanks for this library, it's really useful !