ng-zorro-antd-core-logger.mjs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import { isDevMode } from '@angular/core';
  2. import { environment } from 'ng-zorro-antd/core/environments';
  3. /**
  4. * Use of this source code is governed by an MIT-style license that can be
  5. * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
  6. */
  7. const record = {};
  8. const PREFIX = '[NG-ZORRO]:';
  9. function notRecorded(...args) {
  10. const asRecord = args.reduce((acc, c) => acc + c.toString(), '');
  11. if (record[asRecord]) {
  12. return false;
  13. }
  14. else {
  15. record[asRecord] = true;
  16. return true;
  17. }
  18. }
  19. function consoleCommonBehavior(consoleFunc, ...args) {
  20. if (environment.isTestMode || (isDevMode() && notRecorded(...args))) {
  21. consoleFunc(...args);
  22. }
  23. }
  24. // Warning should only be printed in dev mode and only once.
  25. const warn = (...args) => consoleCommonBehavior((...arg) => console.warn(PREFIX, ...arg), ...args);
  26. // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
  27. const warnDeprecation = (...args) => {
  28. if (!environment.isTestMode) {
  29. const stack = new Error().stack;
  30. return consoleCommonBehavior((...arg) => console.warn(PREFIX, 'deprecated:', ...arg, stack), ...args);
  31. }
  32. else {
  33. return () => { };
  34. }
  35. };
  36. // Log should only be printed in dev mode.
  37. const log = (...args) => {
  38. if (isDevMode()) {
  39. console.log(PREFIX, ...args);
  40. }
  41. };
  42. /**
  43. * Use of this source code is governed by an MIT-style license that can be
  44. * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
  45. */
  46. /**
  47. * Generated bundle index. Do not edit.
  48. */
  49. export { PREFIX, log, warn, warnDeprecation };
  50. //# sourceMappingURL=ng-zorro-antd-core-logger.mjs.map