type LogLevel = 'warn' | 'error' ; function prefixMessage ( message ? ) { return `[glaze] ${ message }` ; } let instance = { warn ( message ? , ... optionalParams ) { console . warn ( prefixMessage ( message ) , ... optionalParams ) ; } , error ( message ? , ... optionalParams ) { console . error ( prefixMessage ( message ) , ... optionalParams ) ; } , } ; export function setLogger ( logger ) { instance = logger ; } const printedMessages = new Map < string , number > ( ) ; function printOnce ( logLevel , message ) { if ( ! printedMessages . has ( message ) ) { instance [ logLevel ] ( message ) ; printedMessages . set ( message , 1 ) ; } } export const warnOnce = printOnce . bind ( null , 'warn' ) ; export const errorOnce = printOnce . bind ( null , 'error' ) ;