Skip to content

Commit c872c3a

Browse files
authored
fix: Expose Client Log Mode (#363)
1 parent d931daa commit c872c3a

File tree

6 files changed

+9
-6
lines changed

6 files changed

+9
-6
lines changed

Packages/ClientRuntime/Sources/Config/DefaultSDKRuntimeConfiguration.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@
77

88
public struct DefaultSDKRuntimeConfiguration: SDKRuntimeConfiguration {
99
public let retryer: SDKRetryer
10-
10+
public var clientLogMode: ClientLogMode
1111
public var logger: LogAgent
1212

13-
public init(_ clientName: String) throws {
13+
public init(_ clientName: String, clientLogMode: ClientLogMode = .request) throws {
1414
self.retryer = try SDKRetryer()
1515
self.logger = SwiftLogger(label: clientName)
16+
self.clientLogMode = clientLogMode
1617
}
1718
}

Packages/ClientRuntime/Sources/Networking/Http/CRT/CRTClientEngine.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public class CRTClientEngine: HttpClientEngine {
8585
// map status code once call comes back
8686
future.then { (responseResult) in
8787
_ = responseResult.map { (response) -> HttpResponse in
88-
self.logger.debug("Future of response came back with success: \(response)")
88+
self.logger.debug("Future of response came back with success")
8989
let statusCode = Int(stream.getResponseStatusCode())
9090
response.statusCode = HttpStatusCode(rawValue: statusCode) ?? HttpStatusCode.notFound
9191
return response

Packages/ClientRuntime/Sources/Networking/Http/HttpResponse.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ public class HttpResponse: HttpUrlResponse {
2727

2828
extension HttpResponse: CustomDebugStringConvertible {
2929
public var debugDescriptionWithBody: String {
30-
return debugDescription + "\n \(body)"
30+
return debugDescription + "\nResponseBody: \(body.debugDescription)"
3131
}
3232
public var debugDescription: String {
33-
return "\(statusCode) \n \(headers)"
33+
return "\nStatus Code: \(statusCode.description) \n \(headers)"
3434
}
3535
}

Packages/ClientRuntime/Sources/Networking/Http/SdkHttpRequest.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ extension SdkHttpRequest {
4444
extension SdkHttpRequest: CustomDebugStringConvertible, CustomStringConvertible {
4545

4646
public var debugDescriptionWithBody: String {
47-
return debugDescription + "\n \(body)"
47+
return debugDescription + "\nRequestBody: \(body.debugDescription)"
4848
}
4949

5050
public var debugDescription: String {

smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/integration/HttpProtocolServiceClient.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ open class HttpProtocolServiceClient(
1919

2020
fun render(serviceSymbol: Symbol) {
2121
writer.openBlock("public class ${serviceSymbol.name} {", "}") {
22+
writer.write("public static let clientName = \"${serviceSymbol.name}\"")
2223
writer.write("let client: \$N", ClientRuntimeTypes.Http.SdkHttpClient)
2324
writer.write("let config: \$N", serviceConfig.typesToConformConfigTo.first())
2425
writer.write("let serviceName = \"${serviceName}\"")

smithy-swift-codegen/src/test/kotlin/HttpProtocolClientGeneratorTests.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class HttpProtocolClientGeneratorTests {
1616
contents.shouldContainOnlyOnce(
1717
"""
1818
public class RestJsonProtocolClient {
19+
public static let clientName = "RestJsonProtocolClient"
1920
let client: ClientRuntime.SdkHttpClient
2021
let config: ClientRuntime.SDKRuntimeConfiguration
2122
let serviceName = "Rest Json Protocol"

0 commit comments

Comments
 (0)