logger.js 1.4 KB

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