import * as vscode from 'vscode' ; import { Logger } from 'cloudlatex-cli-plugin' ; import * as dateformat from 'dateformat' ; export default class VSLogger extends Logger { constructor ( private logPanel ) { super ( ) ; } _log ( m , ... o ) { this . _appendToLogPanel ( 'Log  ' , m , ... o ) ; console . log ( m , ... o ) ; } ; _info ( m , ... o ) { this . _appendToLogPanel ( 'Info ' , m , ... o ) ; console . info ( m , ... o ) ; vscode . window . showInformationMessage ( m , ... o ) ; } ; _warn ( m , ... o ) { this . _appendToLogPanel ( 'Warn ' , m , ... o ) ; console . warn ( m , ... o ) ; vscode . window . showWarningMessage ( m , ... o ) ; } ; _error ( m , ... o ) { this . _appendToLogPanel ( 'Error' , m , ... o ) ; console . error ( m , ... o ) ; vscode . window . showErrorMessage ( m , ... o ) ; } ; _appendToLogPanel ( type , m , ... o ) { const now = new Date ( ) ; const timeStr = dateformat ( now , 'hh:MM:ss' ) ; const message = [ m , ... ( o || [ ] ) ] . map ( o => { if ( typeof o === 'string' ) { return o ; } return JSON . stringify ( o ) ; } ) . join ( ' ' ) ; this . logPanel . appendLine ( `[${ type } - ${ timeStr }] ${ message }` ) ; } }