ConsoleOutputDisableExpressionTemplate.ts 930 B

123456789101112131415161718192021222324
  1. /**
  2. * @returns {string}
  3. */
  4. export function ConsoleOutputDisableExpressionTemplate (): string {
  5. return `
  6. const {consoleLogDisableFunctionName} = {callControllerFunctionName}(this, function () {
  7. {globalVariableTemplate}
  8. const _console = (that.console = that.console || {});
  9. const methods = ['log', 'warn', 'info', 'error', 'exception', 'table', 'trace'];
  10. for (let index = 0; index < methods.length; index++){
  11. const func = {callControllerFunctionName}.constructor();
  12. const methodName = methods[index];
  13. const originalFunction = _console[methodName] || func;
  14. func.toString = originalFunction.toString.bind(originalFunction);
  15. _console[methodName] = func;
  16. };
  17. });
  18. {consoleLogDisableFunctionName}();
  19. `;
  20. }