@@ -8,6 +8,7 @@ import { IDisposable, Disposable } from 'vs/base/common/lifecycle';
88import { isWindows } from 'vs/base/common/platform' ;
99import { Event , Emitter } from 'vs/base/common/event' ;
1010import { IEnvironmentService } from 'vs/platform/environment/common/environment' ;
11+ import { LoggerChannelClient } from 'vs/platform/log/common/logIpc' ;
1112
1213export const ILogService = createServiceDecorator < ILogService > ( 'logService' ) ;
1314
@@ -183,6 +184,54 @@ export class ConsoleLogService extends AbstractLogService implements ILogService
183184 dispose ( ) : void { }
184185}
185186
187+ export class ConsoleLogInMainService extends AbstractLogService implements ILogService {
188+
189+ _serviceBrand : undefined ;
190+
191+ constructor ( private readonly client : LoggerChannelClient , logLevel : LogLevel = DEFAULT_LOG_LEVEL ) {
192+ super ( ) ;
193+ this . setLevel ( logLevel ) ;
194+ }
195+
196+ trace ( message : string , ...args : any [ ] ) : void {
197+ if ( this . getLevel ( ) <= LogLevel . Trace ) {
198+ this . client . consoleLog ( 'trace' , [ message , ...args ] ) ;
199+ }
200+ }
201+
202+ debug ( message : string , ...args : any [ ] ) : void {
203+ if ( this . getLevel ( ) <= LogLevel . Debug ) {
204+ this . client . consoleLog ( 'debug' , [ message , ...args ] ) ;
205+ }
206+ }
207+
208+ info ( message : string , ...args : any [ ] ) : void {
209+ if ( this . getLevel ( ) <= LogLevel . Info ) {
210+ this . client . consoleLog ( 'info' , [ message , ...args ] ) ;
211+ }
212+ }
213+
214+ warn ( message : string | Error , ...args : any [ ] ) : void {
215+ if ( this . getLevel ( ) <= LogLevel . Warning ) {
216+ this . client . consoleLog ( 'warn' , [ message , ...args ] ) ;
217+ }
218+ }
219+
220+ error ( message : string , ...args : any [ ] ) : void {
221+ if ( this . getLevel ( ) <= LogLevel . Error ) {
222+ this . client . consoleLog ( 'error' , [ message , ...args ] ) ;
223+ }
224+ }
225+
226+ critical ( message : string , ...args : any [ ] ) : void {
227+ if ( this . getLevel ( ) <= LogLevel . Critical ) {
228+ this . client . consoleLog ( 'critical' , [ message , ...args ] ) ;
229+ }
230+ }
231+
232+ dispose ( ) : void { }
233+ }
234+
186235export class MultiplexLogService extends AbstractLogService implements ILogService {
187236 _serviceBrand : undefined ;
188237
@@ -326,4 +375,4 @@ export function getLogLevel(environmentService: IEnvironmentService): LogLevel {
326375 }
327376 }
328377 return DEFAULT_LOG_LEVEL ;
329- }
378+ }
0 commit comments