You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've already searched in many places and haven't found a transporter yet for sending out emails at an error level. So I already tried implementing my own like:
importbuildfrom"pino-abstract-transport";importsendServerErrorfrom"../email/sendServerError";functiongetLoggerEmailTransport(){consttransport=build(asyncfunction(source){forawait(constobjofsource){try{sendServerError(obj);}catch(err){console.log("Failed to report error",err);}}});returntransport;}exportdefaultgetLoggerEmailTransport;
... which will use the nodemailer.
This fails under ts-node or jiti with the following error message:
import build from "pino-abstract-transport";
^^^^^^
SyntaxError: Cannot use import statement outside a module
That's because of this difficult code inside pino's transport-stream:
if(toLoad.endsWith('.ts')||toLoad.endsWith('.cts')){// TODO: add support for the TSM modules loader ( https://github.com/lukeed/tsm ).if(process[Symbol.for('ts-node.register.instance')]){realRequire('ts-node/register')}elseif(process.env&&process.env.TS_NODE_DEV){realRequire('ts-node-dev')}// TODO: Support ES imports once tsc, tap & ts-node provide better compatibility guarantees.fn=realRequire(decodeURIComponent(target))}else{fn=(awaitrealImport(toLoad))}
Yeah, there is the TODO comment to improve this. It's a bit ugly. I wonder why the target has to be a string. Can't it be a file import right away, something like this?
import getLoggerEmailTransport from "./getLoggerEmailTransport"
transportTargets.push({
target: getLoggerEmailTransport, <---- this, reuse the import, no string
level: LogLevel.ERROR,
});
Enough questions :)
Thoughts? Happy to discuss further here.
The text was updated successfully, but these errors were encountered:
I'm digging this library and learning more about it. Grazie for all the hard work
Surprised there is no email support yet in the Pino Ecosystem:
https://github.com/pinojs/pino/blob/main/docs/ecosystem.md
So, raising two issues here:
I'll explain ...
I've already searched in many places and haven't found a transporter yet for sending out emails at an error level. So I already tried implementing my own like:
and
... which will use the nodemailer.
This fails under
ts-node
orjiti
with the following error message:That's because of this difficult code inside pino's transport-stream:
Yeah, there is the TODO comment to improve this. It's a bit ugly. I wonder why the
target
has to be a string. Can't it be a file import right away, something like this?Enough questions :)
Thoughts? Happy to discuss further here.
The text was updated successfully, but these errors were encountered: