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

update example to Pino v7 + transports #20

Open
quintesse opened this issue May 18, 2023 · 2 comments
Open

update example to Pino v7 + transports #20

quintesse opened this issue May 18, 2023 · 2 comments

Comments

@quintesse
Copy link

It would be nice if the example could be updated to the latest version of Pino and would show the usage of transports. Especially because the issue I'm seeing is that transport modules get removed at build time because webpack thinks they are not being used.

@Enalmada
Copy link

Enalmada commented Jul 14, 2023

@quintesse have you found a way to stop transport modules getting removed at build time?

I have not been able to work around this and trying to figure out what other people are doing to get pino working in next.js

 error Error [TypeError]: pino__WEBPACK_IMPORTED_MODULE_1___default(...).transport is not a function
    at <unknown> (webpack-internal:///(middleware)/./src/lib/logging/log-util.ts:25)
    at getLogger (webpack-internal:///(middleware)/./src/lib/logging/log-util.ts:25:72)
    at eval (webpack-internal:///(middleware)/./src/middleware.ts:26:80)

After some research, I suspect it has something to do with this
pinojs/pino-pretty#411
and this might solve it
https://github.com/pinojs/pino-webpack-plugin

@quintesse
Copy link
Author

Hi @Enalmada . What I did was add unneeded imports for the transports. Like this:

import pino, { Logger, ... } from 'pino';

// Force Nextjs to keep these modules around!
import 'pino-pretty';
import 'pino-mongodb';
import '@logtail/pino';

.
.

transport = pino.transport({
    targets: [{
      target: "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