
import { isDevMode } from '@angular/core';
import { NzSafeAny } from 'ng-zorro-antd/core/types';

const record: Record<string, boolean> = {};

function notRecorded(...args: NzSafeAny[]): boolean {
  const asRecord = args.reduce((acc, c) => acc + c.toString(), '');

  if (record[asRecord]) {
    return false;
  } else {
    record[asRecord] = true;
    return true;
  }
}

export const log = (scope: string, ...args: NzSafeAny[]) => {
  if (isDevMode() && notRecorded([scope, ...args])) {
    const stack = new Error().stack;
    console.warn(`[@bixi/core] ${scope}`, ...args, stack);
  }
};
