Repository URL to install this package:
|
Version:
0.0.0-beeb224 ▾
|
/**
* This file holds the implementation details of adding the test transport to the winston logger,
* so that the log is readable in the test environment, and we don't pollute the local folder with files.
*/
const Transport = require('winston-transport');
/**
* This winston transport pushes the logs into an array, so that they are readable in tests.
*/
class InMemoryTransport extends Transport {
constructor(options = {}) {
super(options);
this._log = [];
}
log(info, callback) {
setImmediate(() => this.emit('logged', info));
this._log.push(info);
if (callback) {
callback();
}
}
getLog() {
return this._log;
}
clearLog() {
this._log = [];
}
}
module.exports = InMemoryTransport;