fix(lib/vscode): register LogLevelChannel
This commit is contained in:
parent
050a1bb146
commit
ae02023454
@ -66,50 +66,6 @@
|
|||||||
return new Promise((c, e) => fs.writeFile(file, content, 'utf8', err => err ? e(err) : c()));
|
return new Promise((c, e) => fs.writeFile(file, content, 'utf8', err => err ? e(err) : c()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} userDataPath
|
|
||||||
* @returns {object}
|
|
||||||
*/
|
|
||||||
function getLanguagePackConfigurations(userDataPath) {
|
|
||||||
const configFile = path.join(userDataPath, 'languagepacks.json');
|
|
||||||
try {
|
|
||||||
return nodeRequire(configFile);
|
|
||||||
} catch (err) {
|
|
||||||
// Do nothing. If we can't read the file we have no
|
|
||||||
// language pack config.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function readFile(file) {
|
|
||||||
return new Promise(function (resolve, reject) {
|
|
||||||
fs.readFile(file, 'utf8', function (err, data) {
|
|
||||||
if (err) {
|
|
||||||
reject(err);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
resolve(data);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} file
|
|
||||||
* @param {string} content
|
|
||||||
* @returns {Promise<void>}
|
|
||||||
*/
|
|
||||||
function writeFile(file, content) {
|
|
||||||
return new Promise(function (resolve, reject) {
|
|
||||||
fs.writeFile(file, content, 'utf8', function (err) {
|
|
||||||
if (err) {
|
|
||||||
reject(err);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
resolve();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} userDataPath
|
* @param {string} userDataPath
|
||||||
* @returns {object}
|
* @returns {object}
|
||||||
|
@ -330,6 +330,11 @@ export class ExtensionEnvironmentChannel implements IServerChannel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
NOTE@coder:
|
||||||
|
Reference: - ../../workbench/api/common/extHostDebugService.ts
|
||||||
|
3/16/21 jsjoeio
|
||||||
|
*/
|
||||||
class VariableResolverService extends AbstractVariableResolverService {
|
class VariableResolverService extends AbstractVariableResolverService {
|
||||||
constructor(
|
constructor(
|
||||||
remoteAuthority: string,
|
remoteAuthority: string,
|
||||||
@ -355,7 +360,7 @@ class VariableResolverService extends AbstractVariableResolverService {
|
|||||||
NOTE@coder: not sure where we could get this from. This is new.
|
NOTE@coder: not sure where we could get this from. This is new.
|
||||||
@jsjoeio 3/11/21
|
@jsjoeio 3/11/21
|
||||||
*/
|
*/
|
||||||
return undefined;
|
return (args.resolverEnv && args.resolverEnv['VSCODE_CWD']) || env['VSCODE_CWD'] || process.cwd();
|
||||||
},
|
},
|
||||||
getExecPath: (): string | undefined => {
|
getExecPath: (): string | undefined => {
|
||||||
// Assuming that resolverEnv is just for use in the resolver and not for
|
// Assuming that resolverEnv is just for use in the resolver and not for
|
||||||
|
@ -29,7 +29,7 @@ import { ServiceCollection } from 'vs/platform/instantiation/common/serviceColle
|
|||||||
import { ILocalizationsService } from 'vs/platform/localizations/common/localizations';
|
import { ILocalizationsService } from 'vs/platform/localizations/common/localizations';
|
||||||
import { LocalizationsService } from 'vs/platform/localizations/node/localizations';
|
import { LocalizationsService } from 'vs/platform/localizations/node/localizations';
|
||||||
import { ConsoleLogger, getLogLevel, ILoggerService, ILogService, MultiplexLogService } from 'vs/platform/log/common/log';
|
import { ConsoleLogger, getLogLevel, ILoggerService, ILogService, MultiplexLogService } from 'vs/platform/log/common/log';
|
||||||
import { LoggerChannel } from 'vs/platform/log/common/logIpc';
|
import { LogLevelChannel } from 'vs/platform/log/common/logIpc';
|
||||||
import { LoggerService } from 'vs/platform/log/node/loggerService';
|
import { LoggerService } from 'vs/platform/log/node/loggerService';
|
||||||
import { SpdLogLogger } from 'vs/platform/log/node/spdlogLog';
|
import { SpdLogLogger } from 'vs/platform/log/node/spdlogLog';
|
||||||
import product from 'vs/platform/product/common/product';
|
import product from 'vs/platform/product/common/product';
|
||||||
@ -214,7 +214,7 @@ export class Vscode {
|
|||||||
private async initializeServices(args: NativeParsedArgs): Promise<void> {
|
private async initializeServices(args: NativeParsedArgs): Promise<void> {
|
||||||
/*
|
/*
|
||||||
NOTE@coder: this initializeServices is loosely based off this file:
|
NOTE@coder: this initializeServices is loosely based off this file:
|
||||||
https://github.com/cdr/code-server/blob/main/lib/vscode/src/vs/code/electron-browser/sharedProcess/sharedProcessMain.ts#L148
|
Reference: - ../../electron-browser/sharedProcess/sharedProcessMain.ts#L148
|
||||||
|
|
||||||
If upstream changes cause conflicts, look there ^.
|
If upstream changes cause conflicts, look there ^.
|
||||||
3/11/21 @jsjoeio
|
3/11/21 @jsjoeio
|
||||||
@ -224,7 +224,7 @@ export class Vscode {
|
|||||||
fs.mkdirSync(environmentService.globalStorageHome.fsPath, { recursive: true });
|
fs.mkdirSync(environmentService.globalStorageHome.fsPath, { recursive: true });
|
||||||
/*
|
/*
|
||||||
NOTE@coder: Made these updates on based on this file (and lines):
|
NOTE@coder: Made these updates on based on this file (and lines):
|
||||||
https://github.com/cdr/code-server/blob/main/lib/vscode/src/vs/code/electron-browser/sharedProcess/sharedProcessMain.ts#L144-L149
|
Reference: - ../../electron-browser/sharedProcess/sharedProcessMain.ts#L144-L149
|
||||||
|
|
||||||
More details (from @code-asher):
|
More details (from @code-asher):
|
||||||
I think the logLevel channel is only used in the electron version of vscode so we can probably skip it.
|
I think the logLevel channel is only used in the electron version of vscode so we can probably skip it.
|
||||||
@ -234,7 +234,7 @@ export class Vscode {
|
|||||||
*/
|
*/
|
||||||
const logService = new MultiplexLogService([
|
const logService = new MultiplexLogService([
|
||||||
new ConsoleLogger(getLogLevel(environmentService)),
|
new ConsoleLogger(getLogLevel(environmentService)),
|
||||||
new SpdLogLogger(RemoteExtensionLogFileName, path.join(environmentService.logsPath, 'server.log'), false, getLogLevel(environmentService))
|
new SpdLogLogger(RemoteExtensionLogFileName, path.join(environmentService.logsPath, `${RemoteExtensionLogFileName}.log`), false, getLogLevel(environmentService))
|
||||||
]);
|
]);
|
||||||
const fileService = new FileService(logService);
|
const fileService = new FileService(logService);
|
||||||
fileService.registerProvider(Schemas.file, new DiskFileSystemProvider(logService));
|
fileService.registerProvider(Schemas.file, new DiskFileSystemProvider(logService));
|
||||||
@ -250,7 +250,13 @@ export class Vscode {
|
|||||||
...environmentService.extraBuiltinExtensionPaths,
|
...environmentService.extraBuiltinExtensionPaths,
|
||||||
];
|
];
|
||||||
|
|
||||||
this.ipc.registerChannel('logger', new LoggerChannel(loggerService));
|
/*
|
||||||
|
NOTE@coder: we changed this channel registration from LogLevel to LogLevelChannel
|
||||||
|
because it changed upstream.
|
||||||
|
|
||||||
|
3/15/21 jsjoeio
|
||||||
|
*/
|
||||||
|
this.ipc.registerChannel('logger', new LogLevelChannel(logService));
|
||||||
this.ipc.registerChannel(ExtensionHostDebugBroadcastChannel.ChannelName, new ExtensionHostDebugBroadcastChannel());
|
this.ipc.registerChannel(ExtensionHostDebugBroadcastChannel.ChannelName, new ExtensionHostDebugBroadcastChannel());
|
||||||
|
|
||||||
this.services.set(ILogService, logService);
|
this.services.set(ILogService, logService);
|
||||||
|
@ -5,8 +5,8 @@
|
|||||||
|
|
||||||
import { ProxyChannel } from 'vs/base/parts/ipc/common/ipc';
|
import { ProxyChannel } from 'vs/base/parts/ipc/common/ipc';
|
||||||
import { ILocalizationsService } from 'vs/platform/localizations/common/localizations';
|
import { ILocalizationsService } from 'vs/platform/localizations/common/localizations';
|
||||||
import { ISharedProcessService } from 'vs/platform/ipc/electron-sandbox/services';
|
|
||||||
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
|
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
|
||||||
|
import { IRemoteAgentService } from '../../remote/common/remoteAgentService';
|
||||||
|
|
||||||
// @ts-ignore: interface is implemented via proxy
|
// @ts-ignore: interface is implemented via proxy
|
||||||
export class LocalizationsService implements ILocalizationsService {
|
export class LocalizationsService implements ILocalizationsService {
|
||||||
@ -14,9 +14,17 @@ export class LocalizationsService implements ILocalizationsService {
|
|||||||
declare readonly _serviceBrand: undefined;
|
declare readonly _serviceBrand: undefined;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@ISharedProcessService sharedProcessService: ISharedProcessService,
|
@IRemoteAgentService remoteAgentService: IRemoteAgentService,
|
||||||
) {
|
) {
|
||||||
return ProxyChannel.toService<ILocalizationsService>(sharedProcessService.getChannel('localizations'));
|
/*
|
||||||
|
NOTE@coder:
|
||||||
|
Upstream, they use the ISharedProcessService.
|
||||||
|
|
||||||
|
We run this on the browser where there is no shared process so it needs to connect
|
||||||
|
to the localization channel through the remote agent.
|
||||||
|
3/16/21 jsjoeio code-asher
|
||||||
|
*/
|
||||||
|
return ProxyChannel.toService<ILocalizationsService>(remoteAgentService.getConnection()!.getChannel('localizations'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user