import chalk , { Chalk } from "chalk" ; export type LogLevel = "verbose" | "silent" | "normal" ; export class Logger { color : Chalk ; constructor ( public level = "normal" ) { this . color = new chalk . constructor ( { level : 1 } ) ; } debug ( ... msg ) { if ( this . level !== "verbose" ) return ; console . log . apply ( console , [ this . color . gray ( "debug" ) , ... msg ] ) ; } log ( ... msg ) { if ( this . level === "silent" ) return ; console . log . apply ( console , [ this . color . cyan ( "info" ) , ... msg ] ) ; } warn ( ... msg ) { if ( this . level === "silent" ) return ; console . error . apply ( console , [ this . color . yellow ( "warn" ) , ... msg ] ) ; } error ( ... msg ) { if ( this . level === "silent" ) return ; console . error . apply ( console , [ this . color . red ( "error" ) , ... msg ] ) ; } errorStack ( stack ) { if ( this . level === "silent" ) return ; console . error ( stack ) ; } write ( d ) { if ( this . level === "silent" ) return ; process . stdout . write ( d ) ; } tick ( ) { if ( this . level === "silent" ) return ; process . stdout . write ( "." ) ; } }