import { Logger , LogLevel } from "./types" ; export class ConsoleLogger implements Logger { _level : LogLevel ; constructor ( lv ? ) { this . _level = lv || "info" ; } warn ( msg ) { return this . info ( msg ) ; } info ( msg ) { if ( this . _level !== "silent" ) { console . log ( msg ) ; } return this ; } error ( obj ) { if ( this . _level !== "silent" ) { console . error ( obj ) ; } return this ; } verbose ( msg , ... objects ) { if ( this . _level === "verbose" ) { console . log ( msg ) ; if ( objects && objects . length ) { objects . forEach ( obj => { console . log ( JSON . stringify ( obj , null , 2 ) ) ; } ) ; } } return this ; } } let _logger = new ConsoleLogger ( ( process . env . BN_LOG as LogLevel ) || "silent" ) ; export function offLogger ( ) { _logger . _level = "silent" ; } export function setupLogger ( ) { _logger = new ConsoleLogger ; } export function getLogger ( ) { return _logger ; }