Skip to content

Commit

Permalink
Refactor output handling and improve log retrieval in help view
Browse files Browse the repository at this point in the history
Signed-off-by: worksofliam <mrliamallan@live.co.uk>
  • Loading branch information
worksofliam committed Jan 21, 2025
1 parent 866b71c commit b1b7286
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 19 deletions.
20 changes: 14 additions & 6 deletions src/Instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,6 @@ export default class Instance {
writeCount: 0
};

private resetOutput() {
this.output.channel.clear();
this.output.content = ``;
this.output.writeCount = 0;
}

private storage: ConnectionStorage;
private emitter: vscode.EventEmitter<IBMiEvent> = new vscode.EventEmitter();
private subscribers: Map<IBMiEvent, SubscriptionMap> = new Map;
Expand All @@ -54,6 +48,20 @@ export default class Instance {
this.emitter.event(e => this.processEvent(e));
}

focusOutput() {
this.output.channel.show();
}

getOutputContent() {
return this.output.content;
}

private resetOutput() {
this.output.channel.clear();
this.output.content = ``;
this.output.writeCount = 0;
}

connect(options: ConnectionOptions): Promise<ConnectionResult> {
const connection = new IBMi();

Expand Down
26 changes: 13 additions & 13 deletions src/ui/views/helpView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,25 +124,25 @@ async function openNewIssue() {

async function downloadLogs() {
const connection = instance.getConnection();
const config = instance.getConfig();
const content = instance.getContent();
const logs: any[] = [];

if (connection && config && content) {
if (connection) {
const content = connection.getContent();
await vscode.window.withProgress({
location: vscode.ProgressLocation.Notification,
title: vscode.l10n.t(`Gathering logs...`),
}, async () => {
// const codeForIBMiLog = connection.getOutputChannelContent();
// if (codeForIBMiLog !== undefined) {
// logs.push({
// label: vscode.l10n.t(`Code for IBM i Log`),
// detail: `${connection?.currentUser}@${connection?.currentHost}`,
// picked: true,
// fileName: 'CodeForIBMi.txt',
// fileContent: Buffer.from(codeForIBMiLog, 'utf8')
// });
// }

const codeForIBMiLog = instance.getOutputContent();
if (codeForIBMiLog !== undefined) {
logs.push({
label: vscode.l10n.t(`Code for IBM i Log`),
detail: `${connection?.currentUser}@${connection?.currentHost}`,
picked: true,
fileName: 'CodeForIBMi.txt',
fileContent: Buffer.from(codeForIBMiLog, 'utf8')
});
}

const debugConfig = await new DebugConfiguration(connection).load();
try {
Expand Down

0 comments on commit b1b7286

Please sign in to comment.