logger.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.Logger = void 0;
  4. var Logger = /** @class */ (function () {
  5. function Logger(displayProcessors, print) {
  6. this.displayProcessors = displayProcessors;
  7. this.print = print;
  8. this.indent = " ";
  9. this.currentIndent = "";
  10. this.lastWasNewLine = false;
  11. }
  12. Logger.prototype.log = function (stuff) {
  13. var _this = this;
  14. stuff.split("\n").forEach(function (line) {
  15. _this.print(line !== "" ? _this.currentIndent + line : line);
  16. });
  17. this.lastWasNewLine = false;
  18. };
  19. Logger.prototype.process = function (object, processFunction) {
  20. var log = "";
  21. this.displayProcessors.forEach(function (displayProcessor) {
  22. log = processFunction(displayProcessor, object, log);
  23. });
  24. this.log(log);
  25. };
  26. Logger.prototype.newLine = function () {
  27. if (!this.lastWasNewLine) {
  28. this.log("");
  29. this.lastWasNewLine = true;
  30. }
  31. };
  32. Logger.prototype.resetIndent = function () {
  33. this.currentIndent = "";
  34. };
  35. Logger.prototype.increaseIndent = function () {
  36. this.currentIndent += this.indent;
  37. };
  38. Logger.prototype.decreaseIndent = function () {
  39. this.currentIndent = this.currentIndent.substr(0, this.currentIndent.length - this.indent.length);
  40. };
  41. return Logger;
  42. }());
  43. exports.Logger = Logger;
  44. //# sourceMappingURL=logger.js.map