pinojs / pino-pretty

🌲Basic prettifier for Pino log lines
MIT License
1.25k stars 147 forks source link

Can't use custom messageFormat function #470

Closed lis355 closed 1 year ago

lis355 commented 1 year ago

I want to use own formatter, it described in manual https://github.com/pinojs/pino-pretty#options

import pino from "pino";

export default pino(pino.transport({
    targets: [
        {
            target: "pino-pretty",
            options: {
                colorize: true,
                ignore: "pid,hostname",
                messageFormat: (log, messageKey, levelLabel) => {
                    return "";
                }
            }
        }
    ]
}));

I had this error


node:internal/per_context/domexception:53
    ErrorCaptureStackTrace(this);
    ^
Waiting for the debugger to disconnect...
DOMException [DataCloneError]: (log, messageKey, levelLabel) => {
                                        return "";
                                } could not be cloned.
    at new DOMException (node:internal/per_context/domexception:53:5)
    at new Worker (node:internal/worker:266:17)
    at createWorker (C:\Programming\JS\diarybot\Code\node_modules\thread-stream\index.js:55:18)
    at new ThreadStream (C:\Programming\JS\diarybot\Code\node_modules\thread-stream\index.js:230:19)
    at buildStream (C:\Programming\JS\diarybot\Code\node_modules\pino\lib\transport.js:21:18)
    at Function.transport (C:\Programming\JS\diarybot\Code\node_modules\pino\lib\transport.js:114:10)
    at file:///C:/Programming/JS/diarybot/Code/tools/logger.js:3:26
    at ModuleJob.run (node:internal/modules/esm/module_job:217:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:308:24)
    at async loadESM (node:internal/process/esm_loader:42:7)
jsumners commented 1 year ago

https://github.com/pinojs/pino/blob/7837851d38e5585b54bc538812852c3c3d602a20/docs/transports.md?plain=1#L71-L86