let logging = false ; export type ILogFunc = ( level : 'info' | 'error' | 'warn' , ... args : any [ ] ) => void ; let logFunc = ( level , ... args ) => console [ level ] ( ... args ) ; export function overwriteLog ( func ) { logFunc = func ; } export interface ILog { info : ( ... args : any [ ] ) => void ; warn : ( ... args : any [ ] ) => void ; error : ( ... args : any [ ] ) => void ; } export const log = { disable ( enable = false ) { logging = enable ; } , enable ( enable = true ) { logging = enable ; } , info ( ... args ) { if ( ! logging ) return ; logFunc ( 'info' , ... args ) ; } , error ( ... args ) { if ( ! logging ) return ; logFunc ( 'error' , ... args ) ; } , warn ( ... args ) { if ( ! logging ) return ; logFunc ( 'warn' , ... args ) ; } } ; export function createLog ( name ) { let options = { tabs : '' } ; return Object . keys ( log ) . reduce ( ( state , key ) => ( { ... state , [ key ] : ( ... args ) => { return log [ key ] ( options . tabs + name , ... args ) ; } } ) , { } ) ; }