pinojs / pino-tee

🌲 tee pino logs into a file, with multiple levels
MIT License
89 stars 17 forks source link

pino.pretty is not a function #17

Closed aaronovz1 closed 3 years ago

aaronovz1 commented 4 years ago

Using the example from the homepage - this does not work anymore on latest version of Pino.

const pino = require('pino');
...
const pretty = pino.pretty();
pretty.pipe(process.stdout);
...

Changing it to

const pretty = pino({
  prettyPrint: { colorize: true }
});

Solves that problem but then this error happens: TypeError: pretty.pipe is not a function

jsumners commented 4 years ago

Would you like to send a PR to correct the docs?

aaronovz1 commented 4 years ago

It's not just the docs that are wrong. See the error at the bottom. How do I fix that so it's compatible with latest pino? pino() doesn't return an object where pipe's can be set it seems.

aaronovz1 commented 4 years ago

Any suggestions on how to fix the pipe error?

jsumners commented 4 years ago

Sorry. I'm not a pino-tee user and I don't have time to investigate. But I'm willing to bet it's just not compatible with pino-pretty. @mcollina might know better.

mcollina commented 4 years ago

I don’t know either :(

reach009 commented 3 years ago

I am facing the same problem as @aaronovz1. Any helps would be appreciated.

const pretty = pino({ prettyPrint: { colorize: true }, }); pretty.pipe(process.stdout); logThrough.pipe(pretty);

reach009 commented 3 years ago

Hi, I am able to make it work with my nodejs express project.

const logger = pino({
  level: process.env.LOG_LEVEL || "info",
  prettyPrint: true,
});

const expressLogger = expressPino({ logger });

I have created a repository with an example of my codes. Feel free to check out on the link below:

https://github.com/reach009/Node-express-pino-logger.git

chienqan commented 2 years ago

Hi guys, I have found out, the reason is the newest version of pino pretty is not support like that let's try, and it is working for me

yarn add pino-pretty@5.1.2