Bunyan has it's "streams": https://github.com/trentm/node-bunyan#streams
Every logger can write to multiple streams.
You can either specify additional streams while creating logger object, or use addStream
method (it is not mentioned in their readme, but it's a public method, that logger uses internally too), for example:
logger.addStream({
type: 'raw',
stream: new MyDatadog(),
closeOnExit: true,
// Here you specify what level should be written to this stream.
// For example, you can use soemthing like `logger.FATAL` here.
level: options.level
});
And then:
function MyDatadog () {
// initialize whatever is needed here
}
MyDatadog.prototype.write = function write (record) {
// write record data wherever you want
// record is an object with things like:
// - record.what
// - record.time
// - record.err
};
MyDatadog.prototype.end = function end () {
// cleanup stuff here
};
Of course, creating own wrapper is not needed if whatever you use (some datadog library?) gives you writable stream which accepts writing JS objects.