ConsoleOutputDisableExpressionTemplate.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /**
  2. * @returns {string}
  3. */
  4. export function ConsoleOutputDisableExpressionTemplate (): string {
  5. return `
  6. var {consoleLogDisableFunctionName} = {singleNodeCallControllerFunctionName}(this, function () {
  7. var getGlobal = Function('return (function() ' + '{}.constructor("return this")( )' + ');');
  8. var func = function () {};
  9. var that = getGlobal();
  10. if (!that.console) {
  11. that.console = (function (func){
  12. var c = {};
  13. c.log = func;
  14. c.warn = func;
  15. c.debug = func;
  16. c.info = func;
  17. c.error = func;
  18. c.exception = func;
  19. c.trace = func;
  20. return c;
  21. })(func);
  22. } else {
  23. that.console.log = func;
  24. that.console.warn = func;
  25. that.console.debug = func;
  26. that.console.info = func;
  27. that.console.error = func;
  28. that.console.exception = func;
  29. that.console.trace = func;
  30. }
  31. });
  32. {consoleLogDisableFunctionName}();
  33. `;
  34. }