parent.js 940 B

1234567891011121314151617181920212223242526272829303132333435
  1. 'use strict';
  2. const { Transform } = require('stream');
  3. module.exports = class Parent extends Transform {
  4. /**
  5. * !!! HERE BE DRAGONS !!!
  6. *
  7. * Constructor function for the Parent which we use to represent
  8. * `winston.Logger` for testing purposes. You SHOULD NOT use this as an
  9. * example for ANYTHING.
  10. * @param {Object} opts - Configuration for this instance.
  11. */
  12. constructor(opts) {
  13. super({
  14. objectMode: true
  15. });
  16. this.levels = opts.levels;
  17. this.level = opts.level;
  18. }
  19. /**
  20. * Basic pass-through write. In `winston` itself this writes to the `_format`
  21. * which itself is then read back and pushed.
  22. * @param {Info} info - Winston log information
  23. * @param {mixed} enc - TODO: add param description.
  24. * @param {Function} callback - Continuation to respond to when complete.
  25. * @returns {undefined}
  26. */
  27. _transform(info, enc, callback) {
  28. this.push(info);
  29. callback();
  30. }
  31. };