Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
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

Logs missing in debugger console using node --inspect #1983

Open
richterdennis opened this issue Jun 3, 2024 · 2 comments
Open

Logs missing in debugger console using node --inspect #1983

richterdennis opened this issue Jun 3, 2024 · 2 comments

Comments

@richterdennis
Copy link

I want to debug my code using node --inspect or node --inspect-brk, but there is not a zero log in the debugger console.

import pino from 'pino';

const logger = pino();

logger.info('Hello World!');
logger.info('Test');

const error = new Error('TestError');
logger.error(error);

setTimeout(() => {
    debugger;
}, 2000);

I tried to write my own transport using node:inspector and inspector.console.log or even a simple console.log. But nothing works.

@mcollina
Copy link
Member

mcollina commented Jun 4, 2024

This would be a fun one to add. Once upon a time we had

https://github.com/pinojs/pino-inspector

But we don't have it anymore because it had little usage.

@richterdennis
Copy link
Author

In the meantime I found out, that the transports are running inside node:worker_threads. I think there is no way to use node:inspector inspector.console inside a worker thread. Maybe there is a solution with inspector.Session, session.connectToMainThread() and session.post('Something.fancy'). It would be much more easier to provide a hook inside the main thread like the logMethod hook but way later where the log object is finalized.

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

No branches or pull requests

2 participants