mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-11 02:32:35 -05:00
Merge from master
This commit is contained in:
59
src/vs/platform/log/node/logIpc.ts
Normal file
59
src/vs/platform/log/node/logIpc.ts
Normal file
@@ -0,0 +1,59 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IChannel, IServerChannel } from 'vs/base/parts/ipc/node/ipc';
|
||||
import { LogLevel, ILogService, DelegatedLogService } from 'vs/platform/log/common/log';
|
||||
import { Event, buffer } from 'vs/base/common/event';
|
||||
|
||||
export class LogLevelSetterChannel implements IServerChannel {
|
||||
|
||||
onDidChangeLogLevel: Event<LogLevel>;
|
||||
|
||||
constructor(private service: ILogService) {
|
||||
this.onDidChangeLogLevel = buffer(service.onDidChangeLogLevel, true);
|
||||
}
|
||||
|
||||
listen(_, event: string): Event<any> {
|
||||
switch (event) {
|
||||
case 'onDidChangeLogLevel': return this.onDidChangeLogLevel;
|
||||
}
|
||||
|
||||
throw new Error(`Event not found: ${event}`);
|
||||
}
|
||||
|
||||
call(_, command: string, arg?: any): Thenable<any> {
|
||||
switch (command) {
|
||||
case 'setLevel': this.service.setLevel(arg);
|
||||
}
|
||||
|
||||
throw new Error(`Call not found: ${command}`);
|
||||
}
|
||||
}
|
||||
|
||||
export class LogLevelSetterChannelClient {
|
||||
|
||||
constructor(private channel: IChannel) { }
|
||||
|
||||
get onDidChangeLogLevel(): Event<LogLevel> {
|
||||
return this.channel.listen('onDidChangeLogLevel');
|
||||
}
|
||||
|
||||
setLevel(level: LogLevel): void {
|
||||
this.channel.call('setLevel', level);
|
||||
}
|
||||
}
|
||||
|
||||
export class FollowerLogService extends DelegatedLogService implements ILogService {
|
||||
_serviceBrand: any;
|
||||
|
||||
constructor(private master: LogLevelSetterChannelClient, logService: ILogService) {
|
||||
super(logService);
|
||||
this._register(master.onDidChangeLogLevel(level => logService.setLevel(level)));
|
||||
}
|
||||
|
||||
setLevel(level: LogLevel): void {
|
||||
this.master.setLevel(level);
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,6 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import * as path from 'path';
|
||||
import { ILogService, LogLevel, NullLogService, AbstractLogService } from 'vs/platform/log/common/log';
|
||||
import * as spdlog from 'spdlog';
|
||||
@@ -13,7 +11,7 @@ export function createSpdLogService(processName: string, logLevel: LogLevel, log
|
||||
// Do not crash if spdlog cannot be loaded
|
||||
try {
|
||||
const _spdlog: typeof spdlog = require.__$__nodeRequire('spdlog');
|
||||
_spdlog.setAsyncMode(8192, 2000);
|
||||
_spdlog.setAsyncMode(8192, 500);
|
||||
const logfilePath = path.join(logsFolder, `${processName}.log`);
|
||||
const logger = new _spdlog.RotatingLogger(processName, logfilePath, 1024 * 1024 * 5, 6);
|
||||
logger.setLevel(0);
|
||||
@@ -25,6 +23,11 @@ export function createSpdLogService(processName: string, logLevel: LogLevel, log
|
||||
return new NullLogService();
|
||||
}
|
||||
|
||||
export function createRotatingLogger(name: string, filename: string, filesize: number, filecount: number): spdlog.RotatingLogger {
|
||||
const _spdlog: typeof spdlog = require.__$__nodeRequire('spdlog');
|
||||
return new _spdlog.RotatingLogger(name, filename, filesize, filecount);
|
||||
}
|
||||
|
||||
class SpdLogService extends AbstractLogService implements ILogService {
|
||||
|
||||
_serviceBrand: any;
|
||||
|
||||
Reference in New Issue
Block a user