Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions workspaces/mi/mi-core/src/state-machine-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ export interface VisualizerLocation {
connectorData?: any[];
previousContext?: any;
env?: { [key: string]: string | undefined };
isLoading?: boolean;
}

export interface PopupVisualizerLocation extends VisualizerLocation {
Expand Down
12 changes: 12 additions & 0 deletions workspaces/mi/mi-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,18 @@
"type": "boolean",
"default": true,
"description": "Update car plugin version automatically"
},
"MI.logging.loggingLevel": {
"type": "string",
"enum": [
"off",
"error",
"warn",
"debug"
],
"default": "error",
"description": "The verbosity of logging. The Order is off < error < warn < debug.",
"scope": "window"
}
}
},
Expand Down
1 change: 1 addition & 0 deletions workspaces/mi/mi-extension/src/RPCLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ async function getContext(projectUri: string): Promise<VisualizerLocation> {
diagnostics: context.diagnostics,
dataMapperProps: context.dataMapperProps,
errors: context.errors,
isLoading: context.isLoading,
env: {
MI_AUTH_ORG: process.env.MI_AUTH_ORG || '',
MI_AUTH_CLIENT_ID: process.env.MI_AUTH_CLIENT_ID || '',
Expand Down
32 changes: 16 additions & 16 deletions workspaces/mi/mi-extension/src/debugger/debugHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import axios from 'axios';
import * as net from 'net';
import { MACHINE_VIEW } from '@wso2/mi-core';
import { getStateMachine } from '../stateMachine';
import { ERROR_LOG, INFO_LOG, logDebug } from '../util/logger';
import { logDebug, LogLevel } from '../util/logger';
import * as toml from "@iarna/toml";
import { DebuggerConfig } from './config';
import { ChildProcess } from 'child_process';
Expand Down Expand Up @@ -104,7 +104,7 @@ export function checkServerReadiness(): Promise<void> {
.then((response: { status: number; data: any; }) => {
if (response.status === 200) {
if (response.data.status === 'ready') {
logDebug('Server is ready with CApp deployed', INFO_LOG);
logDebug('Server is ready with CApp deployed', LogLevel.INFO);
resolve();
} else {
reject(response.data.status);
Expand All @@ -115,7 +115,7 @@ export function checkServerReadiness(): Promise<void> {
if (elapsedTime < maxTimeout) {
setTimeout(checkReadiness, retryInterval);
} else {
logDebug('Timeout reached while checking server readiness', ERROR_LOG);
logDebug('Timeout reached while checking server readiness', LogLevel.ERROR);
reject('CApp has encountered deployment issues. Please refer to the output for error logs.');
}
}
Expand All @@ -126,7 +126,7 @@ export function checkServerReadiness(): Promise<void> {
setTimeout(checkReadiness, retryInterval);
} else {
const errorMsg = error?.errors[0]?.message;
logDebug(`Error while checking for Server readiness: ${errorMsg}`, ERROR_LOG);
logDebug(`Error while checking for Server readiness: ${errorMsg}`, LogLevel.ERROR);
reject(`CApp has encountered deployment issues. Please refer to the output for error logs.`);
}
});
Expand Down Expand Up @@ -224,7 +224,7 @@ export async function executeBuildTask(projectUri: string, serverPath: string, s
const sourceFiles = await getCarFiles(targetDirectory);
if (sourceFiles.length === 0) {
const errorMessage = "No .car files were found in the target directory. Built without copying to the server's carbonapps directory.";
logDebug(errorMessage, ERROR_LOG);
logDebug(errorMessage, LogLevel.ERROR);
reject(errorMessage);
} else {
const targetPath = path.join(serverPath, 'repository', 'deployment', 'server', 'carbonapps');
Expand All @@ -233,7 +233,7 @@ export async function executeBuildTask(projectUri: string, serverPath: string, s
fs.copyFileSync(sourceFile.fsPath, destinationFile);
DebuggerConfig.setCopiedCapp(destinationFile);
});
logDebug('Build and copy tasks executed successfully', INFO_LOG);
logDebug('Build and copy tasks executed successfully', LogLevel.INFO);
resolve();
}
} catch (err) {
Expand Down Expand Up @@ -426,7 +426,7 @@ export async function executeTasks(projectUri: string, serverPath: string, isDeb
resolve();
// Proceed with connecting to the port
} else {
logDebug('Server is running, but the debugger command port not acitve', ERROR_LOG);
logDebug('Server is running, but the debugger command port not acitve', LogLevel.ERROR);
reject(`Server command port isn't actively listening. Stop any running MI servers and restart the debugger.`);
}
});
Expand All @@ -444,7 +444,7 @@ export async function executeTasks(projectUri: string, serverPath: string, isDeb
}
}).catch((error) => {
reject(error);
logDebug(`Error executing BuildTask: ${error}`, ERROR_LOG);
logDebug(`Error executing BuildTask: ${error}`, LogLevel.ERROR);
});
});

Expand All @@ -457,7 +457,7 @@ export async function executeTasks(projectUri: string, serverPath: string, isDeb
resolve();
// Proceed with connecting to the port
} else {
logDebug(`The ${DebuggerConfig.getCommandPort()} port is not actively listening or the timeout has been reached.`, ERROR_LOG);
logDebug(`The ${DebuggerConfig.getCommandPort()} port is not actively listening or the timeout has been reached.`, LogLevel.ERROR);
reject(`Server command port isn't actively listening. Stop any running MI servers and restart the debugger.`);
}
});
Expand Down Expand Up @@ -519,7 +519,7 @@ export async function deleteCapp(serverPath: string): Promise<void> {
resolve();
}
} catch (err) {
logDebug(`Error deleting Capp: ${err}`, ERROR_LOG);
logDebug(`Error deleting Capp: ${err}`, LogLevel.ERROR);
reject(err);
}
});
Expand All @@ -534,7 +534,7 @@ export async function deleteCopiedCapAndLibs() {
await deleteSpecificFiles(copiedLibs);

} catch (err) {
logDebug(`Failed to delete Capp and Libs: ${err}`, ERROR_LOG);
logDebug(`Failed to delete Capp and Libs: ${err}`, LogLevel.ERROR);
throw err;
}
}
Expand All @@ -549,7 +549,7 @@ export async function deleteSpecificFiles(filesToDelete: string[]): Promise<void
}
resolve();
} catch (err) {
logDebug(`Error deleting files: ${err}`, ERROR_LOG);
logDebug(`Error deleting files: ${err}`, LogLevel.ERROR);
reject(err);
}
});
Expand Down Expand Up @@ -581,7 +581,7 @@ export function createTempDebugBatchFile(batchFilePath: string, binPath: string)

fs.readFile(destFilePath, 'utf8', (err, data) => {
if (err) {
logDebug(`Error reading the micro-integrator-debug.bat file: ${err}`, ERROR_LOG);
logDebug(`Error reading the micro-integrator-debug.bat file: ${err}`, LogLevel.ERROR);
reject(`Error while reading the micro-integrator-debug.bat file: ${err}`);
return;
}
Expand All @@ -590,7 +590,7 @@ export function createTempDebugBatchFile(batchFilePath: string, binPath: string)

fs.writeFile(destFilePath, updatedContent, 'utf8', (err) => {
if (err) {
logDebug(`Error writing the micro-integrator-debug.bat file: ${err}`, ERROR_LOG);
logDebug(`Error writing the micro-integrator-debug.bat file: ${err}`, LogLevel.ERROR);
reject(`Error while updating the micro-integrator-debug.bat file: ${err}`);
return;
}
Expand Down Expand Up @@ -622,7 +622,7 @@ export async function readPortOffset(serverConfigPath: string): Promise<number |
}
return undefined;
} catch (error) {
logDebug(`Failed to read or parse deployment.toml: ${error}`, ERROR_LOG);
logDebug(`Failed to read or parse deployment.toml: ${error}`, LogLevel.ERROR);
return undefined;
}
}
Expand Down Expand Up @@ -656,7 +656,7 @@ export async function setManagementCredentials(serverConfigPath: string) {
}
}
} catch (error) {
logDebug(`Failed to read or parse deployment.toml: ${error}`, ERROR_LOG);
logDebug(`Failed to read or parse deployment.toml: ${error}`, LogLevel.ERROR);
}
}

Expand Down
36 changes: 18 additions & 18 deletions workspaces/mi/mi-extension/src/debugger/debugger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { checkServerReadiness, isADiagramView } from './debugHelper';
import { webviews } from '../visualizer/webview';
import { extension } from '../MIExtensionContext';
import { reject } from 'lodash';
import { ERROR_LOG, INFO_LOG, logDebug } from '../util/logger';
import { LogLevel, logDebug } from '../util/logger';

export interface RuntimeBreakpoint {
id: number;
Expand Down Expand Up @@ -83,7 +83,7 @@ export class Debugger extends EventEmitter {
try {
const workspace = vscode.workspace.getWorkspaceFolder(vscode.Uri.file(path));
if (!workspace) {
logDebug(`No workspace found for path: ${path}`, ERROR_LOG);
logDebug(`No workspace found for path: ${path}`, LogLevel.ERROR);
return;
}
const projectUri = workspace.uri.fsPath;
Expand Down Expand Up @@ -133,7 +133,7 @@ export class Debugger extends EventEmitter {
// LS call for breakpoint info
const breakpointInfo = await this.getBreakpointInformation(breakpointPerFile, normalizedPath);
if (!breakpointInfo) {
logDebug(`No breakpoint information available for path: ${normalizedPath}`, ERROR_LOG);
logDebug(`No breakpoint information available for path: ${normalizedPath}`, LogLevel.ERROR);
return vscodeBreakpointsPerFile;
}
// map the runtime breakpoint to the breakpoint info
Expand Down Expand Up @@ -165,7 +165,7 @@ export class Debugger extends EventEmitter {
};
this.runtimeVscodeBreakpointMap.set(runtimeBreakpointInfo, breakpointPerFile[i]);
} else {
logDebug(`Breakpoint Information for ${breakpointPerFile[i]?.filePath}:${breakpointPerFile[i]?.line} is null`, ERROR_LOG);
logDebug(`Breakpoint Information for ${breakpointPerFile[i]?.filePath}:${breakpointPerFile[i]?.line} is null`, LogLevel.ERROR);
}
}

Expand All @@ -178,7 +178,7 @@ export class Debugger extends EventEmitter {
return vscodeBreakpointsPerFile;
}
} catch (error) {
logDebug(`Error updating breakpoints: ${error}`, ERROR_LOG);
logDebug(`Error updating breakpoints: ${error}`, LogLevel.ERROR);
return Promise.reject(error);
}
}
Expand All @@ -187,7 +187,7 @@ export class Debugger extends EventEmitter {
try {
const workspace = vscode.workspace.getWorkspaceFolder(vscode.Uri.file(path));
if (!workspace) {
logDebug(`No workspace found for path: ${path}`, ERROR_LOG);
logDebug(`No workspace found for path: ${path}`, LogLevel.ERROR);
return;
}
const projectUri = workspace.uri.fsPath;
Expand Down Expand Up @@ -225,7 +225,7 @@ export class Debugger extends EventEmitter {
// LS call for breakpoint info
const breakpointInfo = await this.getBreakpointInformation(stepOverBreakpoints, normalizedPath);
if (!breakpointInfo) {
logDebug(`No step-over breakpoint information available for path: ${normalizedPath}`, ERROR_LOG);
logDebug(`No step-over breakpoint information available for path: ${normalizedPath}`, LogLevel.ERROR);
return;
}
// map the runtime breakpoint to the breakpoint info
Expand Down Expand Up @@ -257,7 +257,7 @@ export class Debugger extends EventEmitter {
};
this.stepOverBreakpointMap.set(runtimeBreakpointInfo, stepOverBreakpoints[i]);
} else {
logDebug(`Breakpoint Information for ${stepOverBreakpoints[i]?.filePath}:${stepOverBreakpoints[i]?.line} is null`, ERROR_LOG);
logDebug(`Breakpoint Information for ${stepOverBreakpoints[i]?.filePath}:${stepOverBreakpoints[i]?.line} is null`, LogLevel.ERROR);
}
}
if (this.isDebuggerActive) {
Expand All @@ -274,7 +274,7 @@ export class Debugger extends EventEmitter {
public async getBreakpointInformation(breakpoints: RuntimeBreakpoint[], filePath: string): Promise<BreakpointInfo[]> {
const workspace = vscode.workspace.getWorkspaceFolder(vscode.Uri.file(filePath));
if (!workspace) {
logDebug(`No workspace found for path: ${filePath}`, ERROR_LOG);
logDebug(`No workspace found for path: ${filePath}`, LogLevel.ERROR);
throw new Error(`No workspace found for path: ${filePath}`);
}
const projectUri = workspace.uri.fsPath;
Expand Down Expand Up @@ -391,17 +391,17 @@ export class Debugger extends EventEmitter {
}
resolve();
}).catch((error) => {
logDebug(`Error while sending the resume command: ${error}`, ERROR_LOG);
logDebug(`Error while sending the resume command: ${error}`, LogLevel.ERROR);
reject(`Error while resuming the debugger server: ${error}`);
});

}).catch((error) => {
logDebug(`Error while checking server readiness: ${error}`, ERROR_LOG);
logDebug(`Error while checking server readiness: ${error}`, LogLevel.ERROR);
reject(error);
});

}).catch((error) => {
logDebug(`Error while connecting the debugger to the MI server: ${error}`, ERROR_LOG);
logDebug(`Error while connecting the debugger to the MI server: ${error}`, LogLevel.ERROR);
reject(`Error while connecting the debugger to the MI server: ${error}`);
});
});
Expand All @@ -419,7 +419,7 @@ export class Debugger extends EventEmitter {

// Error handling for the command client
this.commandClient?.on('error', (error) => {
logDebug(`Command client error: ${error}`, ERROR_LOG);
logDebug(`Command client error: ${error}`, LogLevel.ERROR);
reject(error); // Reject the promise if there's an error
});

Expand All @@ -430,7 +430,7 @@ export class Debugger extends EventEmitter {

// Error handling for the event client
this.eventClient?.on('error', (error) => {
logDebug(`Event client error: ${error}`, ERROR_LOG);
logDebug(`Event client error: ${error}`, LogLevel.ERROR);
reject(error);
});

Expand All @@ -450,7 +450,7 @@ export class Debugger extends EventEmitter {
const message = incompleteMessage.slice(0, newlineIndex);

// Call a function with the received message
logDebug(`Event received: ${message}`, INFO_LOG);
logDebug(`Event received: ${message}`, LogLevel.INFO);

// convert to eventData to json
const eventDataJson = JSON.parse(message);
Expand Down Expand Up @@ -591,7 +591,7 @@ export class Debugger extends EventEmitter {
let incompleteMessage = '';

// Send request on the command port
logDebug(`Command: ${request}`, INFO_LOG);
logDebug(`Command: ${request}`, LogLevel.INFO);
this.commandClient?.write(request);

// Listen for response from the command port
Expand All @@ -609,7 +609,7 @@ export class Debugger extends EventEmitter {
const message = incompleteMessage.slice(0, newlineIndex);

// Call a function with the received message
logDebug(`Command response: ${message}`, INFO_LOG);
logDebug(`Command response: ${message}`, LogLevel.INFO);
resolve(message); // Resolve the promise with the message

// Remove the processed message from incompleteMessage
Expand Down Expand Up @@ -644,7 +644,7 @@ export class Debugger extends EventEmitter {

variables.push(jsonResponse);
} catch (error) {
logDebug(`Error sending properties-command for ${context}: ${error}`, ERROR_LOG);
logDebug(`Error sending properties-command for ${context}: ${error}`, LogLevel.ERROR);
}
}
return variables;
Expand Down
6 changes: 3 additions & 3 deletions workspaces/mi/mi-extension/src/debugger/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import * as path from 'path';
import * as vscode from 'vscode';
import * as fs from 'fs';
import { createTempDebugBatchFile, setJavaHomeInEnvironmentAndPath } from './debugHelper';
import { ERROR_LOG, logDebug } from '../util/logger';
import { LogLevel, logDebug } from '../util/logger';
import { Uri, workspace } from "vscode";
import { MVN_COMMANDS } from "../constants";

Expand Down Expand Up @@ -151,7 +151,7 @@ export function getStopTask(serverPath: string): vscode.Task | undefined {
const command = `${binPath} stop`;

if (!fs.existsSync(binPath)) {
logDebug(`${binPath} does not exist`, ERROR_LOG);
logDebug(`${binPath} does not exist`, LogLevel.ERROR);
return;
}

Expand All @@ -177,7 +177,7 @@ export function getStopCommand(serverPath: string): string | undefined {
const command = `"${binPath}" stop`;

if (!fs.existsSync(binPath)) {
logDebug(`${binPath} does not exist`, ERROR_LOG);
logDebug(`${binPath} does not exist`, LogLevel.ERROR);
return;
}

Expand Down
Loading
Loading