recording.js 537 B

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