Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customize caller format #147

Open
thewh1teagle opened this issue Sep 19, 2024 · 1 comment
Open

Customize caller format #147

thewh1teagle opened this issue Sep 19, 2024 · 1 comment

Comments

@thewh1teagle
Copy link

thewh1teagle commented Sep 19, 2024

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.

@github-staff github-staff deleted a comment from AmjedKhaled165 Sep 25, 2024
@mcollina
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants