This ended up being what I had to do. I used the node.js "exec" command to run a shell command, which in this case was the Bash logger command. It worked well.
const { exec } = require('child_process');
exec('logger -p local0.notice "External Monitor ' + process.argv[1] + ' encountered an error: ' + e + '"', (error, stdout, stderr) => {
//Output nothing. If there are errors with the logger command, we don't want to emit them, because if any text is emitted, the external monitor will be considered up.
});
It should also be noted that "process.argv[1]" is just the name of the external monitor. It's passed in to external monitors as one of the arguments (that's just how external monitors work - they pass in some arguments to the script). So this is basically just putting the name of the external monitor that error'ed out into the log, combined with the actual log message, which is in the variable "e" (which comes from a try/catch block that isn't show here, but by convention when exceptions are thrown they pass back a variable called "e" to the catch block, so if you are printing an error inside a catch block, "e" is usually available to print out).
I am sure there has to be some better, native way to do this other than calling the logger command via exec. I'm sure there is probably either a built in facility in node, or some kind of module that would be nicer. So if anyone comes across this in the future and knows of a better way, please post it so we can all learn from it!