import ILogHandler from '@microsoft/sp-core-library/lib/log/ILogHandler' ; import { ServiceScope } from '@microsoft/sp-core-library' ; export enum LogLevel { Verbose = 1 , Info , Warning , Error } export default class LogHandler implements ILogHandler { constructor ( private logLevel ) { } public verbose ( source , message , scope ) { this . log ( source , message , LogLevel . Verbose , scope ) ; } public info ( source , message , scope ) { this . log ( source , message , LogLevel . Info , scope ) ; } public warn ( source , message , scope ) { this . log ( source , message , LogLevel . Warning , scope ) ; } public error ( source , error , scope ) { this . log ( source , error . message , LogLevel . Error , scope ) ; } private log ( source , message , logLevel , scope ) { if ( this . logLevel > logLevel ) { return ; } const msg = `***${ source }: ${ LogLevel [ logLevel ] . toUpperCase ( ) } ${ message }"` ; switch ( logLevel ) { case LogLevel . Verbose : console . log ( msg ) ; break ; case LogLevel . Info : console . info ( msg ) ; break ; case LogLevel . Warning : console . warn ( msg ) ; break ; case LogLevel . Error : console . error ( msg ) ; break ; } } }