pinojs / pino-caller

🌲 Include call site of pino log messages
Other
57 stars 14 forks source link

Customize caller format #147

Open thewh1teagle opened 1 month ago

thewh1teagle commented 1 month ago

I use pino caller to see where errors happens easily.

/*
Set LOG_LEVEL to one of (debug, error, fatal, info, silent, trace, warn)

*/
import pino from "pino";
import pinoCaller from "pino-caller";

var log = pino({
    level: process.env.LOG_LEVEL?.toLowerCase() ?? 'info',
  transport: {
    target: "pino-pretty",
    options: {
        messageFormat: '{msg}',
        ignore: 'pid,hostname,filename',
    }
  },
});
var log = pinoCaller(log)

export default log;

The current output is:

bun run src/index.ts
[14:31:23.288] ERROR <module code (/Volumes/Internal/pino/src/other.ts:3:4)>: other.ts
[14:31:23.297] ERROR <module code (/Volumes/Internal/pino/src/index.ts:3:4)>: index.ts

How can I configure it to be like:

[14:31:23.288] ERROR at /Volumes/Internal/pino/src/other.ts:3:4: other.ts
[14:31:23.297] ERROR at /Volumes/Internal/pino/src/index.ts:3:4: index.ts

Another issue related to pino: it doesn't print the rest parameters I provide like console.log eg. logger.debug('hello', 'world') - only hello printed.

mcollina commented 1 week ago

Thanks for reporting! Would you like to send a Pull Request to address this issue? Remember to add unit tests.