import { IConnection } from 'vscode-languageserver' ; export enum LogLevel { Debug = 0 , Information , Warning , Error , None } export type LogMessage = string | ( ( ) => string ) ; export class export class Log { param { IConnection } connection param { LogLevel } loglevel memberOf constructor ( public readonly connection , public readonly loglevel ) { } param { LogMessage } message memberOf logDebug ( message ) { try { if ( this . loglevel <= LogLevel . Debug ) { let d = new Date ; if ( typeof message === "string" ) this . connection . console . log ( "[Debug - " + d . getHours ( ) + ":" + d . getMinutes ( ) + ":" + d . getSeconds ( ) + "] " + message ) ; else this . connection . console . log ( "[Debug - " + d . getHours ( ) + ":" + d . getMinutes ( ) + ":" + d . getSeconds ( ) + "] " + message ( ) ) ; } } catch ( error ) { } } param { LogMessage } message param { LogLevel } level memberOf log ( message ? , level ? ) { try { if ( ! level ) level = 0 ; if ( ! message ) message = " " ; if ( this . loglevel <= level ) { let d = new Date ; if ( typeof message === "string" ) this . connection . console . log ( message ) ; else this . connection . console . log ( message ( ) ) ; } } catch ( error ) { } } param { LogMessage } message memberOf logInfo ( message ) { try { if ( this . loglevel <= LogLevel . Debug ) { if ( typeof message === "string" ) this . connection . console . info ( message ) ; else this . connection . console . info ( message ( ) ) ; } } catch ( error ) { } } param { LogMessage } message memberOf logWarn ( message ) { try { if ( this . loglevel <= LogLevel . Warning ) { if ( typeof message === "string" ) this . connection . console . warn ( message ) ; else this . connection . console . warn ( message ( ) ) ; } } catch ( error ) { } } param { LogMessage } message memberOf logError ( message ) { try { if ( this . loglevel <= LogLevel . Error ) { if ( typeof message === "string" ) this . connection . console . error ( message ) ; else this . connection . console . error ( message ( ) ) ; } } catch ( error ) { } } param { LogMessage } message memberOf logFatalError ( message ) { try { if ( typeof message === "string" ) this . connection . console . error ( "FATAL ERROR: " + message ) ; else this . connection . console . error ( "FATAL ERROR: " + message ( ) ) ; } catch ( error ) { } } }