import ILogger from "./ILogger" ; import ILoggerStrategy , { LogLevels } from "./ILoggerStrategy" ; import NoLoggerStrategy from "./NoLoggerStrategy" ; import WinstonLoggerStrategy from "./WinstonLoggerStrategy" ; export class Logger implements ILogger { public constructor ( public strategy ) { } public error ( message , contextID ? ) { this . strategy . log ( LogLevels . Error , message , contextID ) ; } public warn ( message , contextID ? ) { this . strategy . log ( LogLevels . Warn , message , contextID ) ; } public info ( message , contextID ? ) { this . strategy . log ( LogLevels . Info , message , contextID ) ; } public verbose ( message , contextID ? ) { this . strategy . log ( LogLevels . Verbose , message , contextID ) ; } public debug ( message , contextID ? ) { this . strategy . log ( LogLevels . Debug , message , contextID ) ; } } const logger = new Logger ( new NoLoggerStrategy ( ) ) ; export param { boolean } enable param { string } logFile export function configLogger ( enable , logFile ? ) { if ( enable ) { logger . strategy = new WinstonLoggerStrategy ( LogLevels . Debug , logFile ) ; } else { logger . strategy = new NoLoggerStrategy ( ) ; } } export default logger ;