Skip to content

Commit e5e6b8b

Browse files
authored
chore: kickoff release
2 parents 3551df8 + a002c54 commit e5e6b8b

File tree

5 files changed

+25
-10
lines changed

5 files changed

+25
-10
lines changed

AmplifyPlugins/Core/AWSPluginsCore/WebSocket/WebSocketClient.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,7 @@ extension WebSocketClient: URLSessionWebSocketDelegate {
250250
switch (nsError.domain, nsError.code) {
251251
case (NSURLErrorDomain.self, NSURLErrorNetworkConnectionLost),
252252
(NSURLErrorDomain.self, NSURLErrorCannotConnectToHost),
253-
(NSURLErrorDomain.self, NSURLErrorTimedOut),
254253
(NSURLErrorDomain.self, NSURLErrorNotConnectedToInternet),
255-
(NSURLErrorDomain.self, NSURLErrorDataNotAllowed),
256254
(NSPOSIXErrorDomain.self, Int(ECONNABORTED)),
257255
(NSPOSIXErrorDomain.self, 57):
258256
self.subject.send(.error(WebSocketClient.Error.connectionLost))

AmplifyPlugins/Logging/Sources/AWSCloudWatchLoggingPlugin/AWSCloudWatchLoggingSession.swift

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,21 @@ final class AWSCloudWatchLoggingSession {
4343
let directory = try directory(for: category, userIdentifier: userIdentifier)
4444
try fileManager.createDirectory(at: directory, withIntermediateDirectories: true)
4545
try (directory as NSURL).setResourceValue(true, forKey: URLResourceKey.isExcludedFromBackupKey)
46-
let cacheMaxSizeInBytes = localStoreMaxSizeInMB * 1048576
46+
47+
// Calculate appropriate file size limit (individual file, not total cache)
48+
// Use a reasonable file size limit that's a fraction of the total cache size
49+
// Ensure it meets the minimum requirement of 1KB
50+
let totalCacheSizeInBytes = localStoreMaxSizeInMB * 1048576
51+
let fileSizeLimitInBytes = max(
52+
LogRotation.minimumFileSizeLimitInBytes,
53+
totalCacheSizeInBytes / LogRotation.fileCountLimit
54+
)
55+
4756
return try RotatingLogger(directory: directory,
4857
category: category,
4958
namespace: namespace,
5059
logLevel: logLevel,
51-
fileSizeLimitInBytes: cacheMaxSizeInBytes)
60+
fileSizeLimitInBytes: fileSizeLimitInBytes)
5261
}
5362

5463
private static func directory(for category: String, userIdentifier: String?, fileManager: FileManager = .default) throws -> URL {

AmplifyPlugins/Logging/Sources/AWSCloudWatchLoggingPlugin/Consumer/CloudWatchLoggingStreamNameFormatter.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,11 @@ struct CloudWatchLoggingStreamNameFormatter {
4444
func formattedStreamName() async -> String {
4545
return "\(await deviceIdentifier ?? "").\(userIdentifier ?? "guest")"
4646
}
47+
48+
// Add the missing deviceIdentifierFromBundle static method
49+
private static func deviceIdentifierFromBundle() -> String? {
50+
// Use bundle identifier as a fallback device identifier
51+
// This provides a consistent identifier per app installation
52+
return Bundle.main.bundleIdentifier
53+
}
4754
}

AmplifyPlugins/Logging/Sources/AWSCloudWatchLoggingPlugin/Persistence/LogRotation.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@ final class LogRotation {
1717
}
1818

1919
static let minimumFileSizeLimitInBytes = 1024 /* 1KB */
20+
static let fileCountLimit: Int = 5
2021

2122
/// The name pattern of files managed by `LogRotation`.
2223
private static let filePattern = #"amplify[.]([0-9])[.]log"#
2324

2425
let directory: URL
25-
let fileCountLimit: Int = 5
26+
2627
let fileSizeLimitInBytes: UInt64
2728

2829
private(set) var currentLogFile: LogFile {
@@ -40,7 +41,7 @@ final class LogRotation {
4041
self.directory = directory.absoluteURL
4142
self.fileSizeLimitInBytes = UInt64(fileSizeLimitInBytes)
4243
self.currentLogFile = try Self.selectNextLogFile(from: self.directory,
43-
fileCountLimit: fileCountLimit,
44+
fileCountLimit: Self.fileCountLimit,
4445
fileSizeLimitInBytes: self.fileSizeLimitInBytes)
4546
}
4647

@@ -55,7 +56,7 @@ final class LogRotation {
5556
/// 3. If no files matching #1 are present, the file with the oldest last modified date is cleared and selected.
5657
func rotate() throws {
5758
self.currentLogFile = try Self.selectNextLogFile(from: self.directory,
58-
fileCountLimit: self.fileCountLimit,
59+
fileCountLimit: Self.fileCountLimit,
5960
fileSizeLimitInBytes: self.fileSizeLimitInBytes)
6061
}
6162

AmplifyPlugins/Predictions/Tests/PredictionsHostApp/AWSPredictionsPluginIntegrationTests/IdentifyBasicIntegrationTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,11 +225,11 @@ class IdentifyBasicIntegrationTests: AWSPredictionsPluginTestBase {
225225
XCTAssertNotNil(result)
226226
XCTAssertFalse(result.fullText.isEmpty)
227227
XCTAssertFalse(result.words.isEmpty)
228-
XCTAssertEqual(result.words.count, 30)
228+
XCTAssertEqual(result.words.count, 28)
229229
XCTAssertFalse(result.rawLineText.isEmpty)
230-
XCTAssertEqual(result.rawLineText.count, 17)
230+
XCTAssertEqual(result.rawLineText.count, 11)
231231
XCTAssertFalse(result.identifiedLines.isEmpty)
232-
XCTAssertEqual(result.identifiedLines.count, 17)
232+
XCTAssertEqual(result.identifiedLines.count, 11)
233233
XCTAssertFalse(result.keyValues.isEmpty)
234234
XCTAssertEqual(result.keyValues.count, 7)
235235
}

0 commit comments

Comments
 (0)