write(rec) { let msg; if (typeof rec === 'string' || rec instanceof String) { console.log(rec); return; } else if (typeof rec === 'object') { const formattedMsg = this._formatter(rec); if (typeof formattedMsg === 'string' || formattedMsg instanceof String) { msg = formattedMsg; } else { console.error('Unable to format message %j', rec); return; } const logLevel = rec.level; if (logLevel <= bunyan.INFO) { console.info(msg); } else if (logLevel <= bunyan.WARN) { console.warn(msg); } else { // logLevel === bunyan.ERROR || bunyan.FATAL console.error(msg); } } }