From 593881639626126fa26c7c0603ddafaee9c04b2f Mon Sep 17 00:00:00 2001 From: mathieu J Date: Wed, 14 Feb 2024 16:59:55 +0200 Subject: [PATCH] :loud_sound: (AccountKit): Add logs to DatabaseOperations --- .../AccountKit/Sources/Database/DatabaseOperations.swift | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Modules/AccountKit/Sources/Database/DatabaseOperations.swift b/Modules/AccountKit/Sources/Database/DatabaseOperations.swift index d01d112a27..ea6b81e5f4 100644 --- a/Modules/AccountKit/Sources/Database/DatabaseOperations.swift +++ b/Modules/AccountKit/Sources/Database/DatabaseOperations.swift @@ -27,10 +27,12 @@ public class DatabaseOperations { if let error { promise(.failure(DatabaseError.customError(error.localizedDescription))) } else { + log.info("Document \(String(describing: documentData.id)) created successfully. 🎉") promise(.success(documentData)) } } } catch { + log.error("\(error.localizedDescription)") promise(.failure(error)) } } @@ -47,11 +49,13 @@ public class DatabaseOperations { do { let object = try document?.data(as: T.self) if let object { + log.info("Document \(String(describing: object.id)) fetched successfully. 🎉") promise(.success(object)) } else { promise(.failure(DatabaseError.documentNotFound)) } } catch { + log.error("\(error.localizedDescription)") promise(.failure(error)) } } @@ -65,11 +69,13 @@ public class DatabaseOperations { self.database.collection(collection.rawValue) .getDocuments { querySnapshot, error in if let error { + log.error("\(error.localizedDescription)") promise(.failure(error)) } else { let objects = querySnapshot?.documents.compactMap { document -> T? in try? document.data(as: T.self) } ?? [] + log.info("\(String(describing: objects.count)) documents fetched successfully. 🎉") promise(.success(objects)) } }