UNPKG

@awayjs/core

Version:
61 lines (60 loc) 1.8 kB
import { PartialImplementationError } from '../errors/PartialImplementationError'; var ERRORS_LOGGED = {}; /** * */ var Debug = /** @class */ (function () { function Debug() { } Debug.breakpoint = function () { Debug['break'](); }; Debug.throwPIROnKeyWordOnly = function (str, enable) { if (enable === void 0) { enable = true; } if (!enable) Debug.keyword = null; else Debug.keyword = str; }; Debug.throwPIR = function (clss, fnc, msg) { if (this.LOG_PI_ERRORS_ONLY_ONCE) { var errorID = clss + fnc; if (ERRORS_LOGGED[errorID]) return; ERRORS_LOGGED[errorID] = true; } Debug.logPIR('PartialImplementationError ' + clss, fnc, msg); if (Debug.THROW_ERRORS) { if (Debug.keyword) { var e = clss + fnc + msg; if (e.indexOf(Debug.keyword) == -1) return; } throw new PartialImplementationError(clss + '.' + fnc + ': ' + msg); } }; Debug.logPIR = function (clss, fnc, msg) { if (msg === void 0) { msg = ''; } if (Debug.LOG_PI_ERRORS) { var message = clss + '.' + fnc; if (msg) message += ': ' + msg; console.warn(message); } }; Debug.log = function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } if (Debug.ENABLE_LOG) console.log(args); }; Debug.THROW_ERRORS = false; Debug.ENABLE_LOG = true; Debug.LOG_PI_ERRORS = true; Debug.LOG_PI_ERRORS_ONLY_ONCE = true; Debug.keyword = null; return Debug; }()); export { Debug };