From de76674123bc1485cabe234321b39c517c920020 Mon Sep 17 00:00:00 2001 From: Sichan Yoo Date: Tue, 26 Nov 2024 08:49:22 -0800 Subject: [PATCH 1/3] Clean up logging --- .../FlexibleChecksumsResponseMiddleware.swift | 2 +- .../FlexibleChecksumsMiddlewareTests.swift | 6 ++-- .../Documentation.docc/logging.md | 28 +++++++++++++++---- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/Sources/Core/AWSClientRuntime/Sources/AWSClientRuntime/Middlewares/FlexibleChecksumsResponseMiddleware.swift b/Sources/Core/AWSClientRuntime/Sources/AWSClientRuntime/Middlewares/FlexibleChecksumsResponseMiddleware.swift index b4b4ba23c55..223171805f5 100644 --- a/Sources/Core/AWSClientRuntime/Sources/AWSClientRuntime/Middlewares/FlexibleChecksumsResponseMiddleware.swift +++ b/Sources/Core/AWSClientRuntime/Sources/AWSClientRuntime/Middlewares/FlexibleChecksumsResponseMiddleware.swift @@ -43,7 +43,7 @@ public struct FlexibleChecksumsResponseMiddleware LogHandler { + var handler = StreamLogHandler.standardOutput(label: label) + handler.logLevel = logLevel + return handler + } + + public init(logLevel: Logger.Level) { + self.logLevel = logLevel + } +} ``` From 504aa44fa10cb618f230eeac5310c991932ad8be Mon Sep 17 00:00:00 2001 From: Sichan Yoo Date: Tue, 26 Nov 2024 09:07:07 -0800 Subject: [PATCH 2/3] Update test --- .../Middlewares/FlexibleChecksumsMiddlewareTests.swift | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Sources/Core/AWSClientRuntime/Tests/AWSClientRuntimeTests/Middlewares/FlexibleChecksumsMiddlewareTests.swift b/Sources/Core/AWSClientRuntime/Tests/AWSClientRuntimeTests/Middlewares/FlexibleChecksumsMiddlewareTests.swift index 06ad27a56b4..55f3e0a825b 100644 --- a/Sources/Core/AWSClientRuntime/Tests/AWSClientRuntimeTests/Middlewares/FlexibleChecksumsMiddlewareTests.swift +++ b/Sources/Core/AWSClientRuntime/Tests/AWSClientRuntimeTests/Middlewares/FlexibleChecksumsMiddlewareTests.swift @@ -16,6 +16,7 @@ import class SmithyStreams.BufferedStream import class SmithyChecksums.ChunkedStream import enum SmithyChecksums.ChecksumMismatchException import AWSClientRuntime +import Logging class FlexibleChecksumsMiddlewareTests: XCTestCase { private var builtContext: Context! @@ -384,17 +385,15 @@ class FlexibleChecksumsMiddlewareTests: XCTestCase { class TestLogger: LogAgent { var label: String - var messages: [(level: LogAgentLevel, message: String)] = [] + var messages: [(level: Logger.Level, message: String)] = [] - var level: LogAgentLevel - - init(label: String = "Test", messages: [(level: LogAgentLevel, message: String)] = [], level: LogAgentLevel = .info) { + init(label: String = "Test", messages: [(level: Logger.Level, message: String)] = [], level: Logger.Level = .info) { self.label = label self.messages = messages self.level = level } - func log(level: LogAgentLevel = .info, message: @autoclosure () -> String, metadata: @autoclosure () -> [String : String]? = nil, source: @autoclosure () -> String = "ChecksumUnitTests", file: String = #file, function: String = #function, line: UInt = #line) { + func log(level: Logger.Level = .info, message: @autoclosure () -> String, metadata: @autoclosure () -> [String : String]? = nil, source: @autoclosure () -> String = "ChecksumUnitTests", file: String = #file, function: String = #function, line: UInt = #line) { messages.append((level: level, message: message())) } } From 558872821f0c735cf3f2b7eb43836c8bb2657f03 Mon Sep 17 00:00:00 2001 From: Sichan Yoo Date: Tue, 26 Nov 2024 09:26:33 -0800 Subject: [PATCH 3/3] Update test --- .../Middlewares/FlexibleChecksumsMiddlewareTests.swift | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Sources/Core/AWSClientRuntime/Tests/AWSClientRuntimeTests/Middlewares/FlexibleChecksumsMiddlewareTests.swift b/Sources/Core/AWSClientRuntime/Tests/AWSClientRuntimeTests/Middlewares/FlexibleChecksumsMiddlewareTests.swift index 55f3e0a825b..c3c31dc38c1 100644 --- a/Sources/Core/AWSClientRuntime/Tests/AWSClientRuntimeTests/Middlewares/FlexibleChecksumsMiddlewareTests.swift +++ b/Sources/Core/AWSClientRuntime/Tests/AWSClientRuntimeTests/Middlewares/FlexibleChecksumsMiddlewareTests.swift @@ -385,15 +385,14 @@ class FlexibleChecksumsMiddlewareTests: XCTestCase { class TestLogger: LogAgent { var label: String - var messages: [(level: Logger.Level, message: String)] = [] + var messages: [(level: Logging.Logger.Level, message: String)] = [] - init(label: String = "Test", messages: [(level: Logger.Level, message: String)] = [], level: Logger.Level = .info) { + init(label: String = "Test", messages: [(level: Logging.Logger.Level, message: String)] = [], level: Logging.Logger.Level = .info) { self.label = label self.messages = messages - self.level = level } - func log(level: Logger.Level = .info, message: @autoclosure () -> String, metadata: @autoclosure () -> [String : String]? = nil, source: @autoclosure () -> String = "ChecksumUnitTests", file: String = #file, function: String = #function, line: UInt = #line) { + func log(level: Logging.Logger.Level = .info, message: @autoclosure () -> String, metadata: @autoclosure () -> [String : String]? = nil, source: @autoclosure () -> String = "ChecksumUnitTests", file: String = #file, function: String = #function, line: UInt = #line) { messages.append((level: level, message: message())) } }