@wix/design-system
Version:
@wix/design-system
41 lines • 1.41 kB
JavaScript
const noop = () => { };
let depLogger = {
log: noop,
};
const LOG_PREFIX = `@wix/design-system: [WARNING] `;
if (process.env.NODE_ENV !== 'production') {
class DeprecationLogger {
constructor() {
this.reportedMessages = new Set();
this.printWarning = (msg) => {
const message = `${LOG_PREFIX}${msg}`;
if (console) {
console.warn(message);
}
try {
// --- Welcome to debugging @wix/design-system ---
// This error was thrown as a convenience so that you can use this stack
// to find the callsite that caused this warning to fire.
throw new Error(message);
}
catch (x) { }
};
this.log = this.log.bind(this);
}
/**
* Log a warning message, once per key. (Calling `log` twice with same key would result in one log)
*
* @memberof DeprecationLogger
*/
log(message) {
if (!this.reportedMessages.has(message)) {
this.reportedMessages.add(message);
this.printWarning(message);
}
}
}
depLogger = new DeprecationLogger();
}
export { depLogger };
export default (msg) => depLogger.log(msg);
//# sourceMappingURL=deprecationLog.js.map