Logger.js 876 B

12345678910111213141516171819202122232425262728
  1. /*
  2. * A very simple class for logging errors
  3. */
  4. Object.defineProperty(exports, "__esModule", { value: true });
  5. var Logger = /** @class */ (function () {
  6. function Logger(name, callback) {
  7. this.name = name;
  8. this.errors = [];
  9. this.callback = callback;
  10. // TODO: should assert that callback is a function
  11. }
  12. Logger.prototype.log = function (err) {
  13. this.errors.push(err);
  14. if (typeof this.callback === 'function') {
  15. this.callback(err);
  16. }
  17. };
  18. Logger.prototype.printOneError = function (e) {
  19. return e.stack;
  20. };
  21. Logger.prototype.printAllErrors = function () {
  22. var _this = this;
  23. return this.errors.reduce(function (agg, e) { return agg + "\n" + _this.printOneError(e); }, '');
  24. };
  25. return Logger;
  26. }());
  27. exports.Logger = Logger;
  28. //# sourceMappingURL=Logger.js.map