recording.js 498 B

1234567891011121314151617181920212223242526272829
  1. const debug = require('debug')('log4js:recording');
  2. const recordedEvents = [];
  3. function configure() {
  4. return function (logEvent) {
  5. debug(`received logEvent, number of events now ${recordedEvents.length + 1}`);
  6. debug('log event was ', logEvent);
  7. recordedEvents.push(logEvent);
  8. };
  9. }
  10. function replay() {
  11. return recordedEvents.slice();
  12. }
  13. function reset() {
  14. recordedEvents.length = 0;
  15. }
  16. module.exports = {
  17. configure,
  18. replay,
  19. playback: replay,
  20. reset,
  21. erase: reset
  22. };