web - use logservice to log why unload was prevented

This commit is contained in:
Benjamin Pasero 2020-10-27 08:17:59 +01:00
parent 4f759fc230
commit 0b1cd268f1
10 changed files with 28 additions and 20 deletions

View file

@ -439,7 +439,6 @@ export class ActivitybarPart extends Part implements IActivityBarService {
if (homeIndicator) {
let codicon = iconRegistry.get(homeIndicator.icon);
if (!codicon) {
console.warn(`Unknown home indicator icon ${homeIndicator.icon}`);
codicon = Codicon.code;
}

View file

@ -91,7 +91,7 @@ class BrowserMain extends Disposable {
);
// Listeners
this.registerListeners(workbench, services.configurationService, services.storageService, services.logService);
this.registerListeners(workbench, services.storageService, services.logService);
// Driver
if (this.configuration.driver) {
@ -115,7 +115,7 @@ class BrowserMain extends Disposable {
});
}
private registerListeners(workbench: Workbench, configurationService: IConfigurationService, storageService: BrowserStorageService, logService: ILogService): void {
private registerListeners(workbench: Workbench, storageService: BrowserStorageService, logService: ILogService): void {
// Layout
const viewport = isIOS && window.visualViewport ? window.visualViewport /** Visual viewport */ : window /** Layout viewport */;
@ -136,7 +136,7 @@ class BrowserMain extends Disposable {
// Workbench Lifecycle
this._register(workbench.onBeforeShutdown(event => {
if (storageService.hasPendingUpdate) {
console.warn('Unload veto: pending storage update');
logService.warn('Unload veto: pending storage update');
event.veto(true); // prevent data loss from pending storage update
}
}));

View file

@ -72,7 +72,7 @@ export class BrowserBackupTracker extends BackupTracker implements IWorkbenchCon
for (const dirtyWorkingCopy of dirtyWorkingCopies) {
if (!this.backupFileService.hasBackupSync(dirtyWorkingCopy.resource, this.getContentVersion(dirtyWorkingCopy))) {
console.warn('Unload veto: pending backups');
this.logService.warn('Unload veto: pending backups');
return true; // dirty without backup: veto
}
}

View file

@ -942,7 +942,7 @@ export class EditorService extends Disposable implements EditorServiceImpl {
// differs from the canonical resource, we print a warning as this means
// the model will not be able to be opened as editor.
if (!isEqual(resource, canonicalResource) && this.modelService?.getModel(resource)) {
console.warn(`EditorService: a model exists for a resource that is not canonical: ${resource.toString(true)}`);
this.logService.warn(`EditorService: a model exists for a resource that is not canonical: ${resource.toString(true)}`);
}
return canonicalResource;

View file

@ -24,6 +24,7 @@ import { IWorkspaceFolderCreationData } from 'vs/platform/workspaces/common/work
import { IWorkspaceEditingService } from 'vs/workbench/services/workspaces/common/workspaceEditing';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { BeforeShutdownEvent, ILifecycleService } from 'vs/workbench/services/lifecycle/common/lifecycle';
import { ILogService } from 'vs/platform/log/common/log';
/**
* A workspace to open in the workbench can either be:
@ -91,7 +92,8 @@ export class BrowserHostService extends Disposable implements IHostService {
@ILabelService private readonly labelService: ILabelService,
@IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService,
@IInstantiationService private readonly instantiationService: IInstantiationService,
@ILifecycleService private readonly lifecycleService: ILifecycleService
@ILifecycleService private readonly lifecycleService: ILifecycleService,
@ILogService private readonly logService: ILogService
) {
super();
@ -121,7 +123,7 @@ export class BrowserHostService extends Disposable implements IHostService {
// Veto the shutdown depending on `window.confirmBeforeClose` setting
const confirmBeforeClose = this.configurationService.getValue<'always' | 'keyboardOnly' | 'never'>('window.confirmBeforeClose');
if (confirmBeforeClose === 'always' || (this.shutdownReason === HostShutdownReason.Keyboard && confirmBeforeClose === 'keyboardOnly')) {
console.warn('Unload veto: window.confirmBeforeClose=true');
this.logService.warn(`Unload veto: window.confirmBeforeClose=${confirmBeforeClose}`);
e.veto(true);
}
@ -373,13 +375,13 @@ export class BrowserHostService extends Disposable implements IHostService {
try {
return await target.requestFullscreen();
} catch (error) {
console.warn('Toggle Full Screen failed'); // https://developer.mozilla.org/en-US/docs/Web/API/Element/requestFullscreen
this.logService.warn('toggleFullScreen(): requestFullscreen failed'); // https://developer.mozilla.org/en-US/docs/Web/API/Element/requestFullscreen
}
} else {
try {
return await document.exitFullscreen();
} catch (error) {
console.warn('Exit Full Screen failed');
this.logService.warn('toggleFullScreen(): exitFullscreen failed');
}
}
}
@ -393,7 +395,7 @@ export class BrowserHostService extends Disposable implements IHostService {
(<any>document).webkitExitFullscreen(); // it's async, but doesn't return a real promise.
}
} catch {
console.warn('Enter/Exit Full Screen failed');
this.logService.warn('toggleFullScreen(): requestFullscreen/exitFullscreen failed');
}
}
}

View file

@ -19,7 +19,7 @@ export class BrowserTextFileService extends AbstractTextFileService {
protected onBeforeShutdown(reason: ShutdownReason): boolean {
if (this.files.models.some(model => model.hasState(TextFileEditorModelState.PENDING_SAVE))) {
console.warn('Unload veto: pending file saves');
this.logService.warn('Unload veto: pending file saves');
return true; // files are pending to be saved: veto
}

View file

@ -37,6 +37,7 @@ import { WORKSPACE_EXTENSION } from 'vs/platform/workspaces/common/workspaces';
import { UTF8, UTF8_with_bom, UTF16be, UTF16le, encodingExists, UTF8_BOM, detectEncodingByBOMFromBuffer, toEncodeReadable, toDecodeStream, IDecodeStreamResult } from 'vs/workbench/services/textfile/common/encoding';
import { consumeStream } from 'vs/base/common/stream';
import { IModeService } from 'vs/editor/common/services/modeService';
import { ILogService } from 'vs/platform/log/common/log';
/**
* The workbench file service implementation implements the raw file service spec and adds additional methods on top.
@ -65,7 +66,8 @@ export abstract class AbstractTextFileService extends Disposable implements ITex
@IPathService private readonly pathService: IPathService,
@IWorkingCopyFileService private readonly workingCopyFileService: IWorkingCopyFileService,
@IUriIdentityService private readonly uriIdentityService: IUriIdentityService,
@IModeService private readonly modeService: IModeService
@IModeService private readonly modeService: IModeService,
@ILogService protected readonly logService: ILogService
) {
super();

View file

@ -29,6 +29,7 @@ import { IWorkingCopyFileService } from 'vs/workbench/services/workingCopy/commo
import { IUriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentity';
import { IModeService } from 'vs/editor/common/services/modeService';
import { INativeHostService } from 'vs/platform/native/electron-sandbox/native';
import { ILogService } from 'vs/platform/log/common/log';
export class NativeTextFileService extends AbstractTextFileService {
@ -49,9 +50,10 @@ export class NativeTextFileService extends AbstractTextFileService {
@IWorkingCopyFileService workingCopyFileService: IWorkingCopyFileService,
@IUriIdentityService uriIdentityService: IUriIdentityService,
@IModeService modeService: IModeService,
@INativeHostService private readonly nativeHostService: INativeHostService
@INativeHostService private readonly nativeHostService: INativeHostService,
@ILogService logService: ILogService
) {
super(fileService, untitledTextEditorService, lifecycleService, instantiationService, modelService, environmentService, dialogService, fileDialogService, textResourceConfigurationService, filesConfigurationService, textModelService, codeEditorService, pathService, workingCopyFileService, uriIdentityService, modeService);
super(fileService, untitledTextEditorService, lifecycleService, instantiationService, modelService, environmentService, dialogService, fileDialogService, textResourceConfigurationService, filesConfigurationService, textModelService, codeEditorService, pathService, workingCopyFileService, uriIdentityService, modeService, logService);
}
async read(resource: URI, options?: IReadTextFileOptions): Promise<ITextFileContent> {

View file

@ -233,7 +233,8 @@ export class TestTextFileService extends BrowserTextFileService {
@IPathService pathService: IPathService,
@IWorkingCopyFileService workingCopyFileService: IWorkingCopyFileService,
@IUriIdentityService uriIdentityService: IUriIdentityService,
@IModeService modeService: IModeService
@IModeService modeService: IModeService,
@ILogService logService: ILogService
) {
super(
fileService,
@ -251,7 +252,8 @@ export class TestTextFileService extends BrowserTextFileService {
pathService,
workingCopyFileService,
uriIdentityService,
modeService
modeService,
logService
);
}

View file

@ -76,7 +76,7 @@ export class TestTextFileService extends NativeTextFileService {
@IFilesConfigurationService filesConfigurationService: IFilesConfigurationService,
@ITextModelService textModelService: ITextModelService,
@ICodeEditorService codeEditorService: ICodeEditorService,
@IPathService athService: IPathService,
@IPathService pathService: IPathService,
@IWorkingCopyFileService workingCopyFileService: IWorkingCopyFileService,
@ILogService logService: ILogService,
@IUriIdentityService uriIdentityService: IUriIdentityService,
@ -96,11 +96,12 @@ export class TestTextFileService extends NativeTextFileService {
filesConfigurationService,
textModelService,
codeEditorService,
athService,
pathService,
workingCopyFileService,
uriIdentityService,
modeService,
nativeHostService
nativeHostService,
logService
);
}