Skip to content

Commit 8fca449

Browse files
committed
impl: configuration for controlling the rest api client log level
1 parent 7d4a8ad commit 8fca449

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

src/main/kotlin/com/coder/toolbox/settings/ReadOnlyCoderSettings.kt

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ interface ReadOnlyCoderSettings {
3838
*/
3939
val fallbackOnCoderForSignatures: SignatureFallbackStrategy
4040

41+
/**
42+
* Controls the logging for the rest client.
43+
*/
44+
val httpClientLogLevel: HttpLoggingVerbosity
45+
4146
/**
4247
* Default CLI binary name based on OS and architecture
4348
*/
@@ -216,4 +221,32 @@ enum class SignatureFallbackStrategy {
216221
else -> NOT_CONFIGURED
217222
}
218223
}
224+
}
225+
226+
enum class HttpLoggingVerbosity {
227+
NONE,
228+
229+
/**
230+
* Logs URL, method, and status
231+
*/
232+
BASIC,
233+
234+
/**
235+
* Logs BASIC + sanitized headers
236+
*/
237+
HEADERS,
238+
239+
/**
240+
* Logs HEADERS + body content
241+
*/
242+
BODY;
243+
244+
companion object {
245+
fun fromValue(value: String?): HttpLoggingVerbosity = when (value?.lowercase(getDefault())) {
246+
"basic" -> BASIC
247+
"headers" -> HEADERS
248+
"body" -> BODY
249+
else -> NONE
250+
}
251+
}
219252
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.coder.toolbox.store
22

33
import com.coder.toolbox.settings.Environment
4+
import com.coder.toolbox.settings.HttpLoggingVerbosity
45
import com.coder.toolbox.settings.ReadOnlyCoderSettings
56
import com.coder.toolbox.settings.ReadOnlyTLSSettings
67
import com.coder.toolbox.settings.SignatureFallbackStrategy
@@ -42,6 +43,8 @@ class CoderSettingsStore(
4243
get() = store[DISABLE_SIGNATURE_VALIDATION]?.toBooleanStrictOrNull() ?: false
4344
override val fallbackOnCoderForSignatures: SignatureFallbackStrategy
4445
get() = SignatureFallbackStrategy.fromValue(store[FALLBACK_ON_CODER_FOR_SIGNATURES])
46+
override val httpClientLogLevel: HttpLoggingVerbosity
47+
get() = HttpLoggingVerbosity.fromValue(store[HTTP_CLIENT_LOG_LEVEL])
4548
override val defaultCliBinaryNameByOsAndArch: String get() = getCoderCLIForOS(getOS(), getArch())
4649
override val binaryName: String get() = store[BINARY_NAME] ?: getCoderCLIForOS(getOS(), getArch())
4750
override val defaultSignatureNameByOsAndArch: String get() = getCoderSignatureForOS(getOS(), getArch())

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ internal const val DISABLE_SIGNATURE_VALIDATION = "disableSignatureValidation"
1414

1515
internal const val FALLBACK_ON_CODER_FOR_SIGNATURES = "signatureFallbackStrategy"
1616

17+
internal const val HTTP_CLIENT_LOG_LEVEL = "httpClientLogLevel"
18+
1719
internal const val BINARY_NAME = "binaryName"
1820

1921
internal const val DATA_DIRECTORY = "dataDirectory"

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy