import { ArgumentOutOfRangeException } from "../Errors" ; import { ILogger } from "./Interfaces" ; import { LogSeverity } from "./LogSeverity" ; export abstract class BaseLogger implements ILogger { private _logLevel : number ; constructor ( logLevel ) { if ( ! logLevel ) { this . _logLevel = LogSeverity . Info ; } else if ( typeof logLevel === 'string' ) { this . _logLevel = LogSeverity . fromString ( logLevel ) ; } else { this . _logLevel = logLevel ; } } info ( message ) { this . filterAndLogMessage ( LogSeverity . Info , message ) ; } warn ( message ) { this . filterAndLogMessage ( LogSeverity . Warn , message ) ; } debug ( message ) { this . filterAndLogMessage ( LogSeverity . Debug , message ) ; } error ( message ) { this . filterAndLogMessage ( LogSeverity . Error , message ) ; } private filterAndLogMessage ( severity , message ) { if ( this . _logLevel <= severity ) { this . logMessage ( severity , message ) ; } } abstract logMessage ( severity , message ) ; abstract logException ( error ) ; } export default BaseLogger ;