Let's say my node.js app is running. If there is an error (I mean ALL errors. Not just the web error. If it goes to Err out, it counts) , how can I call a function to send an email to me?
Basically, before I want it to write to err.out, I want an email sent to me.
I'm using node.js and express.
Edit: I know how to send an email. The question I want to know is how to intercept the error. You know how when there's an error, it logs to out.log? Well, right now, I'm tail -f out.log, monitoring for errors. I can't sit at home all day doing this. I want errors emailed to me anytime it pops up in out.log.
I want all errors emailed to me. (Not just Express errors). If it's logged, I want that error emailed.
You could replace nodes global console.error() function with one implementation sending emails:
console.error = function(msg) {
// send email
// ...
// additionaly log
process.stderr.write(msg);
};
Then every call in every library made to console.error() would call your specific implementation send out mails ;)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With