mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-20 01:25:37 -05:00
Merge from vscode e558dc6ea73a75bd69d7a0b485f0e7e4194c66bf (#6864)
This commit is contained in:
@@ -8,7 +8,6 @@ import { ExtensionActivationTimesBuilder } from 'vs/workbench/api/common/extHost
|
||||
import { AbstractExtHostExtensionService } from 'vs/workbench/api/common/extHostExtensionService';
|
||||
import { endsWith, startsWith } from 'vs/base/common/strings';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import { joinPath } from 'vs/base/common/resources';
|
||||
import { RequireInterceptor } from 'vs/workbench/api/common/extHostRequireInterceptor';
|
||||
|
||||
@@ -128,7 +127,7 @@ export class ExtHostExtensionService extends AbstractExtHostExtensionService {
|
||||
const next = joinPath(parent, '..', ensureSuffix(mod, '.js'));
|
||||
moduleStack.push(next);
|
||||
const trap = ExportsTrap.Instance.add(next.toString());
|
||||
importScripts(asDomUri(next).toString(true));
|
||||
importScripts(next.toString(true));
|
||||
moduleStack.pop();
|
||||
|
||||
return trap.claim();
|
||||
@@ -139,7 +138,7 @@ export class ExtHostExtensionService extends AbstractExtHostExtensionService {
|
||||
module = module.with({ path: ensureSuffix(module.path, '.js') });
|
||||
moduleStack.push(module);
|
||||
const trap = ExportsTrap.Instance.add(module.toString());
|
||||
importScripts(asDomUri(module).toString(true));
|
||||
importScripts(module.toString(true));
|
||||
moduleStack.pop();
|
||||
return Promise.resolve<T>(trap.claim());
|
||||
|
||||
@@ -153,16 +152,6 @@ export class ExtHostExtensionService extends AbstractExtHostExtensionService {
|
||||
}
|
||||
}
|
||||
|
||||
// todo@joh this is a copy of `dom.ts#asDomUri`
|
||||
function asDomUri(uri: URI): URI {
|
||||
if (Schemas.vscodeRemote === uri.scheme) {
|
||||
// rewrite vscode-remote-uris to uris of the window location
|
||||
// so that they can be intercepted by the service worker
|
||||
return URI.parse(window.location.href).with({ path: '/vscode-remote', query: JSON.stringify(uri) });
|
||||
}
|
||||
return uri;
|
||||
}
|
||||
|
||||
function ensureSuffix(path: string, suffix: string): string {
|
||||
return endsWith(path, suffix) ? path : path + suffix;
|
||||
}
|
||||
|
||||
@@ -4,24 +4,33 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { ILogService, LogLevel, AbstractLogService } from 'vs/platform/log/common/log';
|
||||
import { ExtHostLogServiceShape } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { ExtHostLogServiceShape, MainThreadLogShape, MainContext } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { IExtHostInitDataService } from 'vs/workbench/api/common/extHostInitDataService';
|
||||
import { IExtHostOutputService } from 'vs/workbench/api/common/extHostOutput';
|
||||
import * as vscode from 'vscode';
|
||||
import { IExtHostRpcService } from 'vs/workbench/api/common/extHostRpcService';
|
||||
import { joinPath } from 'vs/base/common/resources';
|
||||
import { ExtensionHostLogFileName } from 'vs/workbench/services/extensions/common/extensions';
|
||||
import { UriComponents } from 'vs/base/common/uri';
|
||||
import { localize } from 'vs/nls';
|
||||
|
||||
export class ExtHostLogService extends AbstractLogService implements ILogService, ExtHostLogServiceShape {
|
||||
|
||||
_serviceBrand: any;
|
||||
|
||||
private readonly _logChannel: vscode.OutputChannel;
|
||||
private readonly _proxy: MainThreadLogShape;
|
||||
private readonly _logFile: UriComponents;
|
||||
|
||||
constructor(
|
||||
@IExtHostRpcService rpc: IExtHostRpcService,
|
||||
@IExtHostInitDataService initData: IExtHostInitDataService,
|
||||
@IExtHostOutputService extHostOutputService: IExtHostOutputService
|
||||
) {
|
||||
super();
|
||||
const logFile = joinPath(initData.logsLocation, `${ExtensionHostLogFileName}.log`);
|
||||
this._proxy = rpc.getProxy(MainContext.MainThreadLog);
|
||||
this._logFile = logFile.toJSON();
|
||||
this.setLevel(initData.logLevel);
|
||||
this._logChannel = extHostOutputService.createOutputChannel('Log (Worker Extension Host)');
|
||||
extHostOutputService.createOutputChannelFromLogFile(localize('name', "Worker Extension Host"), logFile);
|
||||
}
|
||||
|
||||
$setLevel(level: LogLevel): void {
|
||||
@@ -30,55 +39,37 @@ export class ExtHostLogService extends AbstractLogService implements ILogService
|
||||
|
||||
trace(_message: string, ..._args: any[]): void {
|
||||
if (this.getLevel() <= LogLevel.Trace) {
|
||||
this._logChannel.appendLine(this._format(arguments));
|
||||
this._proxy.$log(this._logFile, LogLevel.Trace, Array.from(arguments));
|
||||
}
|
||||
}
|
||||
|
||||
debug(_message: string, ..._args: any[]): void {
|
||||
if (this.getLevel() <= LogLevel.Debug) {
|
||||
this._logChannel.appendLine(this._format(arguments));
|
||||
this._proxy.$log(this._logFile, LogLevel.Debug, Array.from(arguments));
|
||||
}
|
||||
}
|
||||
|
||||
info(_message: string, ..._args: any[]): void {
|
||||
if (this.getLevel() <= LogLevel.Info) {
|
||||
this._logChannel.appendLine(this._format(arguments));
|
||||
this._proxy.$log(this._logFile, LogLevel.Info, Array.from(arguments));
|
||||
}
|
||||
}
|
||||
|
||||
warn(_message: string, ..._args: any[]): void {
|
||||
if (this.getLevel() <= LogLevel.Warning) {
|
||||
this._logChannel.appendLine(this._format(arguments));
|
||||
this._proxy.$log(this._logFile, LogLevel.Warning, Array.from(arguments));
|
||||
}
|
||||
}
|
||||
|
||||
error(_message: string | Error, ..._args: any[]): void {
|
||||
if (this.getLevel() <= LogLevel.Error) {
|
||||
this._logChannel.appendLine(this._format(arguments));
|
||||
this._proxy.$log(this._logFile, LogLevel.Error, Array.from(arguments));
|
||||
}
|
||||
}
|
||||
|
||||
critical(_message: string | Error, ..._args: any[]): void {
|
||||
if (this.getLevel() <= LogLevel.Critical) {
|
||||
this._logChannel.appendLine(String(arguments));
|
||||
this._proxy.$log(this._logFile, LogLevel.Critical, Array.from(arguments));
|
||||
}
|
||||
}
|
||||
|
||||
private _format(args: any): string {
|
||||
let result = '';
|
||||
|
||||
for (let i = 0; i < args.length; i++) {
|
||||
let a = args[i];
|
||||
|
||||
if (typeof a === 'object') {
|
||||
try {
|
||||
a = JSON.stringify(a);
|
||||
} catch (e) { }
|
||||
}
|
||||
|
||||
result += (i > 0 ? ' ' : '') + a;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user