Skip to content

Commit f8606a0

Browse files
committed
impl: configure the rest api client log level from the Settings page
This commit adds support for allowing the user to configure the rest api client log level in the Settings page.
1 parent 8fca449 commit f8606a0

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

src/main/kotlin/com/coder/toolbox/store/CoderSettingsStore.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,11 @@ class CoderSettingsStore(
182182
}
183183
}
184184

185+
fun updateHttpClientLogLevel(level: HttpLoggingVerbosity?) {
186+
if (level == null) return
187+
store[HTTP_CLIENT_LOG_LEVEL] = level.toString()
188+
}
189+
185190
fun updateBinaryDirectoryFallback(shouldEnableBinDirFallback: Boolean) {
186191
store[ENABLE_BINARY_DIR_FALLBACK] = shouldEnableBinDirFallback.toString()
187192
}

src/main/kotlin/com/coder/toolbox/views/CoderSettingsPage.kt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
package com.coder.toolbox.views
22

33
import com.coder.toolbox.CoderToolboxContext
4+
import com.coder.toolbox.settings.HttpLoggingVerbosity.BASIC
5+
import com.coder.toolbox.settings.HttpLoggingVerbosity.BODY
6+
import com.coder.toolbox.settings.HttpLoggingVerbosity.HEADERS
7+
import com.coder.toolbox.settings.HttpLoggingVerbosity.NONE
48
import com.jetbrains.toolbox.api.ui.actions.RunnableActionDescription
59
import com.jetbrains.toolbox.api.ui.components.CheckboxField
10+
import com.jetbrains.toolbox.api.ui.components.ComboBoxField
11+
import com.jetbrains.toolbox.api.ui.components.ComboBoxField.LabelledValue
612
import com.jetbrains.toolbox.api.ui.components.TextField
713
import com.jetbrains.toolbox.api.ui.components.TextType
814
import com.jetbrains.toolbox.api.ui.components.UiField
@@ -44,6 +50,18 @@ class CoderSettingsPage(private val context: CoderToolboxContext, triggerSshConf
4450
settings.fallbackOnCoderForSignatures.isAllowed(),
4551
context.i18n.ptrl("Verify binary signature using releases.coder.com when CLI signatures are not available from the deployment")
4652
)
53+
54+
private val httpLoggingField = ComboBoxField(
55+
ComboBoxField.Label(context.i18n.ptrl("HTTP logging level:")),
56+
settings.httpClientLogLevel,
57+
listOf(
58+
LabelledValue(context.i18n.ptrl("None"), NONE, listOf("" to "No logs")),
59+
LabelledValue(context.i18n.ptrl("Basic"), BASIC, listOf("" to "Method, URL and status")),
60+
LabelledValue(context.i18n.ptrl("Header"), HEADERS, listOf("" to " Basic + sanitized headers")),
61+
LabelledValue(context.i18n.ptrl("Body"), BODY, listOf("" to "Headers + body content")),
62+
)
63+
)
64+
4765
private val enableBinaryDirectoryFallbackField =
4866
CheckboxField(
4967
settings.enableBinaryDirectoryFallback,
@@ -80,6 +98,7 @@ class CoderSettingsPage(private val context: CoderToolboxContext, triggerSshConf
8098
enableBinaryDirectoryFallbackField,
8199
disableSignatureVerificationField,
82100
signatureFallbackStrategyField,
101+
httpLoggingField,
83102
dataDirectoryField,
84103
headerCommandField,
85104
tlsCertPathField,
@@ -103,6 +122,7 @@ class CoderSettingsPage(private val context: CoderToolboxContext, triggerSshConf
103122
context.settingsStore.updateEnableDownloads(enableDownloadsField.checkedState.value)
104123
context.settingsStore.updateDisableSignatureVerification(disableSignatureVerificationField.checkedState.value)
105124
context.settingsStore.updateSignatureFallbackStrategy(signatureFallbackStrategyField.checkedState.value)
125+
context.settingsStore.updateHttpClientLogLevel(httpLoggingField.selectedValueState.value)
106126
context.settingsStore.updateBinaryDirectoryFallback(enableBinaryDirectoryFallbackField.checkedState.value)
107127
context.settingsStore.updateHeaderCommand(headerCommandField.contentState.value)
108128
context.settingsStore.updateCertPath(tlsCertPathField.contentState.value)

src/main/resources/localization/defaultMessages.po

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,4 +167,16 @@ msgid "Run anyway"
167167
msgstr ""
168168

169169
msgid "Disable Coder CLI signature verification"
170+
msgstr ""
171+
172+
msgid "None"
173+
msgstr ""
174+
175+
msgid "Basic"
176+
msgstr ""
177+
178+
msgid "Headers"
179+
msgstr ""
180+
181+
msgid "Body"
170182
msgstr ""

0 commit comments

Comments
 (0)