import { ILogger , ILogLevels , LogLevel } from './types' ; export const LogLevels = { SILENT : - 1 , ERROR : 0 , WARN : 1 , INFO : 2 , DEBUG : 3 , } ; export default class Logger implements ILogger { private loggerObject ? : ILogger ; private logLevel : LogLevel = LogLevels . INFO ; private shouldLog ( level ) { return level <= this . logLevel ; } public setLogLevel ( level ) { this . logLevel = level ; return this ; } public setLoggerObject ( loggerObject ) { this . loggerObject = loggerObject ; return this ; } public debug ( message ) { if ( this . loggerObject && this . shouldLog ( LogLevels . DEBUG ) ) { this . loggerObject . debug ( message ) ; } } public info ( message ) { if ( this . loggerObject && this . shouldLog ( LogLevels . INFO ) ) { this . loggerObject . info ( message ) ; } } public warn ( message ) { if ( this . loggerObject && this . shouldLog ( LogLevels . WARN ) ) { this . loggerObject . warn ( message ) ; } } public error ( message ) { if ( this . loggerObject && this . shouldLog ( LogLevels . ERROR ) ) { this . loggerObject . error ( message ) ; } } }