@@ -113,6 +113,7 @@ import { InlineCompletionItemFeature } from './inlineCompletion';
113
113
* Controls when the output channel is revealed.
114
114
*/
115
115
export enum RevealOutputChannelOn {
116
+ Debug = 0 ,
116
117
Info = 1 ,
117
118
Warn = 2 ,
118
119
Error = 3 ,
@@ -983,33 +984,29 @@ export abstract class BaseLanguageClient implements FeatureClient<Middleware, La
983
984
return data . toString ( ) ;
984
985
}
985
986
987
+ public debug ( message : string , data ?: any , showNotification : boolean = true ) : void {
988
+ this . logOutputMessage ( MessageType . Debug , RevealOutputChannelOn . Debug , 'Debug' , message , data , showNotification ) ;
989
+ }
990
+
986
991
public info ( message : string , data ?: any , showNotification : boolean = true ) : void {
987
- this . outputChannel . appendLine ( `[Info - ${ ( new Date ( ) . toLocaleTimeString ( ) ) } ] ${ message } ` ) ;
988
- if ( data !== null && data !== undefined ) {
989
- this . outputChannel . appendLine ( this . data2String ( data ) ) ;
990
- }
991
- if ( showNotification && this . _clientOptions . revealOutputChannelOn <= RevealOutputChannelOn . Info ) {
992
- this . showNotificationMessage ( MessageType . Info , message ) ;
993
- }
992
+ this . logOutputMessage ( MessageType . Info , RevealOutputChannelOn . Info , 'Info' , message , data , showNotification ) ;
994
993
}
995
994
996
995
public warn ( message : string , data ?: any , showNotification : boolean = true ) : void {
997
- this . outputChannel . appendLine ( `[Warn - ${ ( new Date ( ) . toLocaleTimeString ( ) ) } ] ${ message } ` ) ;
998
- if ( data !== null && data !== undefined ) {
999
- this . outputChannel . appendLine ( this . data2String ( data ) ) ;
1000
- }
1001
- if ( showNotification && this . _clientOptions . revealOutputChannelOn <= RevealOutputChannelOn . Warn ) {
1002
- this . showNotificationMessage ( MessageType . Warning , message ) ;
1003
- }
996
+ this . logOutputMessage ( MessageType . Warning , RevealOutputChannelOn . Warn , 'Warn' , message , data , showNotification ) ;
1004
997
}
1005
998
1006
999
public error ( message : string , data ?: any , showNotification : boolean | 'force' = true ) : void {
1007
- this . outputChannel . appendLine ( `[Error - ${ ( new Date ( ) . toLocaleTimeString ( ) ) } ] ${ message } ` ) ;
1000
+ this . logOutputMessage ( MessageType . Error , RevealOutputChannelOn . Error , 'Error' , message , data , showNotification ) ;
1001
+ }
1002
+
1003
+ private logOutputMessage ( type : MessageType , reveal : RevealOutputChannelOn , name : string , message : string , data : any | undefined , showNotification : boolean | 'force' ) : void {
1004
+ this . outputChannel . appendLine ( `[${ name . padEnd ( 5 ) } - ${ ( new Date ( ) . toLocaleTimeString ( ) ) } ] ${ message } ` ) ;
1008
1005
if ( data !== null && data !== undefined ) {
1009
1006
this . outputChannel . appendLine ( this . data2String ( data ) ) ;
1010
1007
}
1011
- if ( showNotification === 'force' || ( showNotification && this . _clientOptions . revealOutputChannelOn <= RevealOutputChannelOn . Error ) ) {
1012
- this . showNotificationMessage ( MessageType . Error , message ) ;
1008
+ if ( showNotification === 'force' || ( showNotification && this . _clientOptions . revealOutputChannelOn <= reveal ) ) {
1009
+ this . showNotificationMessage ( type , message ) ;
1013
1010
}
1014
1011
}
1015
1012
@@ -1115,6 +1112,9 @@ export abstract class BaseLanguageClient implements FeatureClient<Middleware, La
1115
1112
case MessageType . Info :
1116
1113
this . info ( message . message , undefined , false ) ;
1117
1114
break ;
1115
+ case MessageType . Debug :
1116
+ this . debug ( message . message , undefined , false ) ;
1117
+ break ;
1118
1118
default :
1119
1119
this . outputChannel . appendLine ( message . message ) ;
1120
1120
}
0 commit comments