UNPKG

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