Skip to content

Commit 099e284

Browse files
committed
microsoft#40575 Remove action in the output panel. Instead provide a command to open the log file
1 parent 7e6aca1 commit 099e284

10 files changed

Lines changed: 42 additions & 57 deletions

File tree

src/vs/workbench/parts/logs/electron-browser/logs.contribution.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import * as nls from 'vs/nls';
7-
import { join } from 'path';
7+
import { join } from 'vs/base/common/paths';
88
import { Registry } from 'vs/platform/registry/common/platform';
99
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions, IWorkbenchContribution } from 'vs/workbench/common/contributions';
1010
import { IOutputChannelRegistry, Extensions as OutputExt, } from 'vs/workbench/parts/output/common/output';
@@ -17,7 +17,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
1717
import * as Constants from 'vs/workbench/parts/logs/common/logConstants';
1818
import { IWorkbenchActionRegistry, Extensions as WorkbenchActionExtensions } from 'vs/workbench/common/actions';
1919
import { SyncActionDescriptor } from 'vs/platform/actions/common/actions';
20-
import { ShowLogsAction, OpenLogsFolderAction, SetLogLevelAction } from 'vs/workbench/parts/logs/electron-browser/logsActions';
20+
import { ShowLogsAction, OpenLogsFolderAction, SetLogLevelAction, OpenLogFileAction } from 'vs/workbench/parts/logs/electron-browser/logsActions';
2121

2222
class LogOutputChannels extends Disposable implements IWorkbenchContribution {
2323

@@ -40,5 +40,6 @@ Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).regi
4040
const workbenchActionsRegistry = Registry.as<IWorkbenchActionRegistry>(WorkbenchActionExtensions.WorkbenchActions);
4141
const devCategory = nls.localize('developer', "Developer");
4242
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(ShowLogsAction, ShowLogsAction.ID, ShowLogsAction.LABEL), 'Developer: Show Logs...', devCategory);
43+
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(OpenLogFileAction, OpenLogFileAction.ID, OpenLogFileAction.LABEL), 'Developer: Open Log File...', devCategory);
4344
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(OpenLogsFolderAction, OpenLogsFolderAction.ID, OpenLogsFolderAction.LABEL), 'Developer: Open Log Folder', devCategory);
4445
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(SetLogLevelAction, SetLogLevelAction.ID, SetLogLevelAction.LABEL), 'Developer: Set Log Level', devCategory);

src/vs/workbench/parts/logs/electron-browser/logsActions.ts

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ import * as nls from 'vs/nls';
77
import { Action } from 'vs/base/common/actions';
88
import * as paths from 'vs/base/common/paths';
99
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
10-
import { IWindowsService } from 'vs/platform/windows/common/windows';
10+
import { IWindowsService, IWindowService } from 'vs/platform/windows/common/windows';
1111
import { TPromise } from 'vs/base/common/winjs.base';
1212
import { IQuickOpenService, IPickOpenEntry } from 'vs/platform/quickOpen/common/quickOpen';
1313
import { ILogService, LogLevel } from 'vs/platform/log/common/log';
14-
import { IOutputService } from 'vs/workbench/parts/output/common/output';
14+
import { IOutputService, COMMAND_OPEN_LOG_VIEWER } from 'vs/workbench/parts/output/common/output';
1515
import * as Constants from 'vs/workbench/parts/logs/common/logConstants';
16+
import { ICommandService } from 'vs/platform/commands/common/commands';
17+
import URI from 'vs/base/common/uri';
1618

1719
export class OpenLogsFolderAction extends Action {
1820

@@ -61,6 +63,38 @@ export class ShowLogsAction extends Action {
6163
}
6264
}
6365

66+
export class OpenLogFileAction extends Action {
67+
68+
static ID = 'workbench.action.openLogFile';
69+
static LABEL = nls.localize('openLogFile', "Open Log File...");
70+
71+
constructor(id: string, label: string,
72+
@IQuickOpenService private quickOpenService: IQuickOpenService,
73+
@IEnvironmentService private environmentService: IEnvironmentService,
74+
@ICommandService private commandService: ICommandService,
75+
@IWindowService private windowService: IWindowService
76+
) {
77+
super(id, label);
78+
}
79+
80+
run(): TPromise<void> {
81+
const entries: IPickOpenEntry[] = [
82+
{ id: URI.file(paths.join(this.environmentService.logsPath, `main.log`)).fsPath, label: nls.localize('mainProcess', "Main") },
83+
{ id: URI.file(paths.join(this.environmentService.logsPath, `sharedprocess.log`)).fsPath, label: nls.localize('sharedProcess', "Shared") },
84+
{ id: URI.file(paths.join(this.environmentService.logsPath, `renderer${this.windowService.getCurrentWindowId()}.log`)).fsPath, label: nls.localize('rendererProcess', "Window") },
85+
{ id: URI.file(paths.join(this.environmentService.logsPath, `extHost${this.windowService.getCurrentWindowId()}.log`)).fsPath, label: nls.localize('extensionHost', "Extension Host") }
86+
];
87+
88+
return this.quickOpenService.pick(entries, { placeHolder: nls.localize('selectProcess', "Select process") })
89+
.then(entry => {
90+
if (entry) {
91+
return this.commandService.executeCommand(COMMAND_OPEN_LOG_VIEWER, URI.file(entry.id));
92+
}
93+
return null;
94+
});
95+
}
96+
}
97+
6498
export class SetLogLevelAction extends Action {
6599

66100
static ID = 'workbench.action.setLogLevel';

src/vs/workbench/parts/output/browser/media/open_file.svg

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/vs/workbench/parts/output/browser/media/open_file_inverse.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/vs/workbench/parts/output/browser/media/open_log.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/vs/workbench/parts/output/browser/media/output.css

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,6 @@
1212
background: url('clear_output_inverse.svg') center center no-repeat;
1313
}
1414

15-
.monaco-workbench .output-action.open-log-viewer {
16-
background: url('open_log.svg') center center no-repeat;
17-
}
18-
19-
.vs-dark .monaco-workbench .output-action.open-log-viewer,
20-
.hc-black .monaco-workbench .output-action.open-log-viewer {
21-
background: url('open_file_inverse.svg') center center no-repeat;
22-
}
23-
2415
.monaco-workbench .output-action.output-scroll-lock {
2516
background: url('output_lock.svg') center center no-repeat;
2617
}

src/vs/workbench/parts/output/browser/outputActions.ts

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -53,23 +53,6 @@ export class ClearOutputAction extends Action {
5353
}
5454
}
5555

56-
export class OpenInLogViewerAction extends Action {
57-
58-
public static readonly ID = 'workbench.output.action.openInLogViewer';
59-
public static readonly LABEL = nls.localize('openInLogViewer', "Open in Log Viewer");
60-
61-
constructor(
62-
id: string, label: string,
63-
@IOutputService private outputService: IOutputService
64-
) {
65-
super(id, label, 'output-action open-log-viewer');
66-
}
67-
68-
public run(): TPromise<any> {
69-
return this.outputService.showChannelInEditor(this.outputService.getActiveChannel().id);
70-
}
71-
}
72-
7356
export class ToggleOutputScrollLockAction extends Action {
7457

7558
public static readonly ID = 'workbench.output.action.toggleOutputScrollLock';

src/vs/workbench/parts/output/browser/outputPanel.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
1919
import { EditorInput, EditorOptions } from 'vs/workbench/common/editor';
2020
import { TextResourceEditor } from 'vs/workbench/browser/parts/editor/textResourceEditor';
2121
import { OUTPUT_PANEL_ID, IOutputService, CONTEXT_IN_OUTPUT } from 'vs/workbench/parts/output/common/output';
22-
import { SwitchOutputAction, SwitchOutputActionItem, ClearOutputAction, ToggleOutputScrollLockAction, OpenInLogViewerAction } from 'vs/workbench/parts/output/browser/outputActions';
22+
import { SwitchOutputAction, SwitchOutputActionItem, ClearOutputAction, ToggleOutputScrollLockAction } from 'vs/workbench/parts/output/browser/outputActions';
2323
import { IThemeService } from 'vs/platform/theme/common/themeService';
2424
import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService';
2525
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
@@ -55,7 +55,6 @@ export class OutputPanel extends TextResourceEditor {
5555
this.actions = [
5656
this.instantiationService.createInstance(SwitchOutputAction),
5757
this.instantiationService.createInstance(ClearOutputAction, ClearOutputAction.ID, ClearOutputAction.LABEL),
58-
this.instantiationService.createInstance(OpenInLogViewerAction, OpenInLogViewerAction.ID, OpenInLogViewerAction.LABEL),
5958
this.instantiationService.createInstance(ToggleOutputScrollLockAction, ToggleOutputScrollLockAction.ID, ToggleOutputScrollLockAction.LABEL)
6059
];
6160

src/vs/workbench/parts/output/common/output.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,6 @@ export interface IOutputService {
8181
*/
8282
showChannel(id: string, preserveFocus?: boolean): TPromise<void>;
8383

84-
/**
85-
* Show the channel with the give id in editor
86-
*/
87-
showChannelInEditor(id: string): TPromise<void>;
88-
8984
/**
9085
* Allows to register on active output channel change.
9186
*/

src/vs/workbench/parts/output/electron-browser/outputServices.ts

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
1515
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
1616
import { Registry } from 'vs/platform/registry/common/platform';
1717
import { EditorOptions } from 'vs/workbench/common/editor';
18-
import { IOutputChannelIdentifier, IOutputChannel, IOutputService, Extensions, OUTPUT_PANEL_ID, IOutputChannelRegistry, OUTPUT_SCHEME, OUTPUT_MIME, MAX_OUTPUT_LENGTH, LOG_SCHEME, COMMAND_OPEN_LOG_VIEWER } from 'vs/workbench/parts/output/common/output';
18+
import { IOutputChannelIdentifier, IOutputChannel, IOutputService, Extensions, OUTPUT_PANEL_ID, IOutputChannelRegistry, OUTPUT_SCHEME, OUTPUT_MIME, MAX_OUTPUT_LENGTH, LOG_SCHEME } from 'vs/workbench/parts/output/common/output';
1919
import { OutputPanel } from 'vs/workbench/parts/output/browser/outputPanel';
2020
import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
2121
import { IModelService } from 'vs/editor/common/services/modelService';
@@ -37,9 +37,7 @@ import { IWindowService } from 'vs/platform/windows/common/windows';
3737
import { ILogService } from 'vs/platform/log/common/log';
3838
import { binarySearch } from 'vs/base/common/arrays';
3939
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
40-
import { IMessageService, Severity } from 'vs/platform/message/common/message';
4140
import { Schemas } from 'vs/base/common/network';
42-
import { ICommandService } from 'vs/platform/commands/common/commands';
4341

4442
const OUTPUT_ACTIVE_CHANNEL_KEY = 'output.activechannel';
4543

@@ -377,9 +375,7 @@ export class OutputService extends Disposable implements IOutputService, ITextMo
377375
@IEnvironmentService environmentService: IEnvironmentService,
378376
@IWindowService windowService: IWindowService,
379377
@ITelemetryService private telemetryService: ITelemetryService,
380-
@ILogService private logService: ILogService,
381-
@IMessageService private messageService: IMessageService,
382-
@ICommandService private commandService: ICommandService
378+
@ILogService private logService: ILogService
383379
) {
384380
super();
385381
const channels = this.getChannels();
@@ -420,15 +416,6 @@ export class OutputService extends Disposable implements IOutputService, ITextMo
420416
return promise.then(() => this._onActiveOutputChannel.fire(id));
421417
}
422418

423-
showChannelInEditor(channelId: string): TPromise<void> {
424-
const channel = <OutputChannel>this.getChannel(channelId);
425-
if (channel.file) {
426-
return this.commandService.executeCommand(COMMAND_OPEN_LOG_VIEWER, channel.file);
427-
}
428-
this.messageService.show(Severity.Info, nls.localize('noFile', "There is no file associated to this channel"));
429-
return TPromise.as(null);
430-
}
431-
432419
getChannel(id: string): IOutputChannel {
433420
if (!this.channels.has(id)) {
434421
this.channels.set(id, this.createChannel(id));

0 commit comments

Comments
 (0)