Skip to content

Commit

Permalink
Update launch wizard to use dropdowns for log levels
Browse files Browse the repository at this point in the history
Closes #1152
  • Loading branch information
shanedell committed Jan 27, 2025
1 parent 57df26c commit e9b16b1
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 7 deletions.
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

0 comments on commit e9b16b1

Please sign in to comment.