Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update launch wizard to use dropdowns for log levels #1153

Merged
merged 1 commit into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
39 changes: 37 additions & 2 deletions src/launchWizard/launchWizard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ export async function activate(ctx: vscode.ExtensionContext) {
)
}

function getAllowedLogLevels(toLower: boolean = false): string[] {
let logLevels: string[] = []
;['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'].forEach((logLevel) => {
logLevels.push(toLower ? logLevel.toLowerCase() : logLevel)
})
return logLevels
}

// Function to get config values
function getConfigValues(data, configIndex) {
if (data && configIndex !== -1) {
Expand Down Expand Up @@ -508,7 +516,30 @@ class LaunchWizard {
})

let dfdlDebugger: DFDLDebugger = defaultValues.dfdlDebugger
let debuggerLogLevelSelect = ''
let debuggerLogLevelTypes = getAllowedLogLevels()
let debuggerLogLevel = dfdlDebugger.logging.level

debuggerLogLevelTypes.forEach((type) => {
if (type === debuggerLogLevel) {
debuggerLogLevelSelect += `<option selected value="${type}">${type}</option>`
} else {
debuggerLogLevelSelect += `<option value="${type}">${type}</option>`
}
})

let dataEditor: DataEditorConfig = defaultValues.dataEditor
let dataEditorLogLevelSelect = ''
let dataEditorLogLevelTypes = getAllowedLogLevels(true)
let dataEditorLogLevel = dataEditor.logging.level

dataEditorLogLevelTypes.forEach((type) => {
if (type === dataEditorLogLevel) {
dataEditorLogLevelSelect += `<option selected value="${type}">${type}</option>`
} else {
dataEditorLogLevelSelect += `<option value="${type}">${type}</option>`
}
})

return `
<!DOCTYPE html>
Expand Down Expand Up @@ -600,7 +631,9 @@ class LaunchWizard {
<input class="file-input" value="${dfdlDebugger.logging.file}" id="dfdlDebuggerLogFile">

<p id="dfdlDebuggerLogLevelLabel" style="margin-top: 10px;" class="setting-description">Log Level:</p>
<input class="file-input" value="${dfdlDebugger.logging.level}" id="dfdlDebuggerLogLevel">
<select class="file-input" style="width: 200px;" id="dfdlDebuggerLogLevel">
${debuggerLogLevelSelect}
</select>
</div>

<div id="useExistingServerDiv" class="setting-div" onclick="check('useExistingServer')">
Expand Down Expand Up @@ -710,7 +743,9 @@ class LaunchWizard {
<input class="file-input" value="${dataEditor.logging.file}" id="dataEditorLogFile">

<p id="dataEditorLogLevelLabel" style="margin-top: 10px;" class="setting-description">Log Level:</p>
<input class="file-input" value="${dataEditor.logging.level}" id="dataEditorLogLevel">
<select class="file-input" style="width: 200px;" id="dataEditorLogLevel">
${dataEditorLogLevelSelect}
</select>
</div>

<br/>
Expand Down
5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -782,11 +782,6 @@
resolved "https://registry.npmjs.org/@xtuc/long/-/long-4.2.2.tgz"
integrity sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ==

acorn-import-assertions@^1.9.0:
version "1.9.0"
resolved "https://registry.npmjs.org/acorn-import-assertions/-/acorn-import-assertions-1.9.0.tgz"
integrity sha512-cmMwop9x+8KFhxvKrKfPYmN6/pKTYYHBqLa0DfvVZcKMJWNyWLnaqND7dx/qn66R7ewM1UX5XMaDVP5wlVTaVA==

acorn-walk@^8.1.1:
version "8.2.0"
resolved "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz"
Expand Down