diff --git a/Sources/SwiftUICoordinator/Coordinator/Coordinator.swift b/Sources/SwiftUICoordinator/Coordinator/Coordinator.swift index eba8b97..ec84f77 100644 --- a/Sources/SwiftUICoordinator/Coordinator/Coordinator.swift +++ b/Sources/SwiftUICoordinator/Coordinator/Coordinator.swift @@ -15,6 +15,8 @@ public protocol Coordinator: AnyObject { var parent: Coordinator? { get } /// An array that stores references to any child coordinators. var childCoordinators: [WeakCoordinator] { get set } + /// Coordinator type name + var name: String { get } /// Takes action parameter and handles the `CoordinatorAction`. func handle(_ action: CoordinatorAction) /// Adds child coordinator to the list. @@ -27,11 +29,19 @@ public protocol Coordinator: AnyObject { public extension Coordinator { + // MARK: - Public properties + + var name: String { + return String(describing: type(of: self)) + } + // MARK: - Public methods func add(child: Coordinator) { guard !childCoordinators.contains(where: { $0 === child }) else { - Logger.coordinator.warning("Attempted to add a coordinator that is already a child.") + Logger.coordinator.warning( + "Attempted to add a coordinator that is already a child: \(self.name)" + ) return } @@ -40,5 +50,6 @@ public extension Coordinator { func remove(coordinator: Coordinator) { childCoordinators.removeAll(where: { $0.coordinator === coordinator }) + Logger.coordinator.notice("Removed coordinator: \(self.name)") } } diff --git a/Sources/SwiftUICoordinator/Coordinator/CoordinatorDeepLinkHandling.swift b/Sources/SwiftUICoordinator/Coordinator/CoordinatorDeepLinkHandling.swift index c678b4b..0393bfe 100644 --- a/Sources/SwiftUICoordinator/Coordinator/CoordinatorDeepLinkHandling.swift +++ b/Sources/SwiftUICoordinator/Coordinator/CoordinatorDeepLinkHandling.swift @@ -1,5 +1,5 @@ // -// File.swift +// CoordinatorDeepLinkHandling.swift // // // Created by Erik Drobne on 12. 10. 23. diff --git a/Sources/SwiftUICoordinator/Coordinator/WeakCoordinator.swift b/Sources/SwiftUICoordinator/Coordinator/WeakCoordinator.swift index 8712b83..77a82fc 100644 --- a/Sources/SwiftUICoordinator/Coordinator/WeakCoordinator.swift +++ b/Sources/SwiftUICoordinator/Coordinator/WeakCoordinator.swift @@ -1,5 +1,5 @@ // -// File.swift +// WeakCoordinator.swift // // // Created by Erik Drobne on 9. 10. 23. diff --git a/Sources/SwiftUICoordinator/DeepLink/DeepLinkError.swift b/Sources/SwiftUICoordinator/DeepLink/DeepLinkError.swift index 7fb8269..a82e087 100644 --- a/Sources/SwiftUICoordinator/DeepLink/DeepLinkError.swift +++ b/Sources/SwiftUICoordinator/DeepLink/DeepLinkError.swift @@ -1,5 +1,5 @@ // -// File.swift +// DeepLinkError.swift // // // Created by Erik Drobne on 13/09/2023. diff --git a/Sources/SwiftUICoordinator/DeepLink/DeepLinkHandling.swift b/Sources/SwiftUICoordinator/DeepLink/DeepLinkHandling.swift index e2cbdba..a0d0aab 100644 --- a/Sources/SwiftUICoordinator/DeepLink/DeepLinkHandling.swift +++ b/Sources/SwiftUICoordinator/DeepLink/DeepLinkHandling.swift @@ -1,5 +1,5 @@ // -// File.swift +// DeepLinkHandling.swift // // // Created by Erik Drobne on 13/09/2023.