@@ -116,6 +116,7 @@ export interface ILogger {
116116 info : ( message : string , ...args : any [ ] ) => void ;
117117 warn : ( message : string , ...args : any [ ] ) => void ;
118118 error : ( message : string , ...args : any [ ] ) => void ;
119+ focus : ( ) => void ;
119120}
120121
121122export enum LogLevel {
@@ -164,6 +165,40 @@ export class VsCodeLogger implements ILogger {
164165 error ( message : string , ...args : any [ ] ) {
165166 this . logGeneric ( LogLevel . Error , 'ERROR' , message , ...args ) ;
166167 }
168+ focus ( ) {
169+ this . channel . show ( true ) ;
170+ }
171+ }
172+
173+ export class VsCodeLogChannelLogger implements ILogger {
174+ constructor (
175+ readonly channel : vscode . LogOutputChannel ) {
176+ }
177+
178+ debug ( message : string , ...args : any [ ] ) {
179+ this . channel . debug ( message , ...args ) ;
180+ }
181+
182+ info ( message : string , ...args : any [ ] ) {
183+ this . channel . info ( message , ...args ) ;
184+ }
185+
186+ warn ( message : string , ...args : any [ ] ) {
187+ this . channel . warn ( message , ...args ) ;
188+ }
189+
190+ error ( message : string , ...args : any [ ] ) {
191+ let err = undefined ;
192+ if ( args . length > 0 && args [ args . length - 1 ] instanceof Error ) {
193+ err = args . pop ( ) ;
194+ }
195+
196+ this . channel . error ( message , args ) ;
197+ this . channel . error ( err ) ;
198+ }
199+ focus ( ) {
200+ this . channel . show ( true ) ;
201+ }
167202}
168203
169204export interface IDebuggerFacade {
@@ -588,6 +623,7 @@ let hasArrayLengthFeature: boolean | undefined = undefined;
588623let logOutputLanguageEnabled : boolean | undefined = undefined ;
589624let hasWorkspaceFs : boolean | undefined = undefined ;
590625let hasUriJoinPath : boolean | undefined = undefined ;
626+ let hasLogOutputChannel : boolean | undefined = undefined ;
591627
592628export class Features {
593629 static versionAtLeast ( ver : string ) {
@@ -635,6 +671,14 @@ export class Features {
635671 }
636672 return hasUriJoinPath ;
637673 }
674+
675+ static hasLogOutputChannel ( ) {
676+ if ( hasLogOutputChannel === undefined ) {
677+ hasLogOutputChannel = this . versionAtLeast ( '1.74.0' ) ;
678+ }
679+
680+ return hasLogOutputChannel ;
681+ }
638682}
639683
640684export function joinPath ( base : vscode . Uri , ...paths : string [ ] ) {
0 commit comments