Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,18 @@ final class AWSCloudWatchLoggingSession {
let directory = try directory(for: category, userIdentifier: userIdentifier)
try fileManager.createDirectory(at: directory, withIntermediateDirectories: true)
try (directory as NSURL).setResourceValue(true, forKey: URLResourceKey.isExcludedFromBackupKey)
let cacheMaxSizeInBytes = localStoreMaxSizeInMB * 1048576

// Calculate appropriate file size limit (individual file, not total cache)
// Use a reasonable file size limit that's a fraction of the total cache size
// Ensure it meets the minimum requirement of 1KB
let totalCacheSizeInBytes = localStoreMaxSizeInMB * 1048576
let fileSizeLimitInBytes = max(LogRotation.minimumFileSizeLimitInBytes, totalCacheSizeInBytes / 5)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why totalCacheSizeInBytes / 5 ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update the code to better reflect what 5 was.. Its the file count.


return try RotatingLogger(directory: directory,
category: category,
namespace: namespace,
logLevel: logLevel,
fileSizeLimitInBytes: cacheMaxSizeInBytes)
fileSizeLimitInBytes: fileSizeLimitInBytes)
}

private static func directory(for category: String, userIdentifier: String?, fileManager: FileManager = .default) throws -> URL {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,11 @@ struct CloudWatchLoggingStreamNameFormatter {
func formattedStreamName() async -> String {
return "\(await deviceIdentifier ?? "").\(userIdentifier ?? "guest")"
}

// Add the missing deviceIdentifierFromBundle static method
private static func deviceIdentifierFromBundle() -> String? {
// Use bundle identifier as a fallback device identifier
// This provides a consistent identifier per app installation
return Bundle.main.bundleIdentifier
}
}
Loading