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

Selective formatting of Pino output while preserving third-party output #472

Open
hanszoons opened this issue Oct 13, 2023 · 5 comments
Open

Comments

@hanszoons
Copy link

I frequently use pino-pretty alongside other tools (e.g., test runners). When I pipe the output to npx pino-pretty, the formatting of everything not generated by pino gets erased. Is there a way to instruct pino-pretty to only format the output originating from pino (ndjson), while keeping the output from third-party tools that interweaves completely intact?

@jsumners
Copy link
Member

That's what the tool is designed to do:

if (!isObject(inputData)) {
const parsed = jsonParser(inputData)
if (parsed.err || !isObject(parsed.value)) {
// pass through
return inputData + this.EOL
}
log = parsed.value
} else {

@hanszoons
Copy link
Author

But yet all formatting is removed on whatever is passed through?
image
left: npx vitest, right: npx vitest | npx pino-pretty

@jsumners
Copy link
Member

If it isn't piping to stdin then there is nothing we can do about it.

@hanszoons
Copy link
Author

I'm afraid I don't understand, is there anything I can do about it myself?

@jsumners
Copy link
Member

I do not know what npx vitest does to write its output to the terminal. But some-app | pino-pretty will do as desired if some-app is writing its output to stdout such that it pipes to the stdin of pino-pretty.

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