import { LogEntry , LogStructuredData } from "./LogEntry" ; import { LogLevel } from "./LogLevel" ; import { Reporter } from "./reporters/Reporter" ; import { NpmLogReporter } from "./reporters/NpmLogReporter" ; export class Logger { static reporters : Reporter [ ] = [ new NpmLogReporter ( { logLevel : LogLevel . info } ) , ] ; logs : LogEntry [ ] = [ ] ; log ( level , msg , data ? ) { const entry = { timestamp : Date . now ( ) , level , msg , data , } ; this . logs . push ( entry ) ; for ( const reporter of Logger . reporters ) { reporter . log ( entry ) ; } } info ( msg , data ? ) { this . log ( LogLevel . info , msg , data ) ; } warn ( msg , data ? ) { this . log ( LogLevel . warn , msg , data ) ; } error ( msg , data ? ) { this . log ( LogLevel . error , msg , data ) ; } verbose ( msg , data ? ) { this . log ( LogLevel . verbose , msg , data ) ; } silly ( msg , data ? ) { this . log ( LogLevel . silly , msg , data ) ; } }