Skip to content

Commit

Permalink
Fix remove by destination type, add tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
aronbudinszky committed Jul 1, 2024
1 parent 39852cf commit c10614c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ DerivedData/
.swiftpm/configuration/registries.json
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.netrc
/.idea
2 changes: 1 addition & 1 deletion Sources/MELogger/Managers/MELoggerDestinationManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ final public class MELoggerDestinationManager: @unchecked Sendable {
/// - Parameter destinationType: The class of the destination to remove.
public func remove(type destinationType: MELoggerDestination.Type) {
self.loggerDestinationListMutatingLock.sync {
self.destinations = []
self.destinations.removeAll(where: { type(of: $0) == destinationType })
}
}

Expand Down
13 changes: 11 additions & 2 deletions Tests/MELoggerTests/MELoggerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,18 @@ class MELoggerTests: XCTestCase {
XCTAssertEqual(1, anotherMockLogDestination.loggedMessages.count)
XCTAssertNotNil(self.mockLogDestination.lastLoggedMessage)
XCTAssertEqual(2, self.mockLogDestination.loggedMessages.count)

}


func testAddRemoveLoggerDestionations() {
XCTAssertEqual(MELoggerDestinationManager.shared.getDestinations().count, 0)
let fileLoggerDestination = FileLoggerDestination()
MELoggerDestinationManager.shared.add(self.mockLogDestination)
MELoggerDestinationManager.shared.add(fileLoggerDestination)
XCTAssertEqual(MELoggerDestinationManager.shared.getDestinations().count, 2)
MELoggerDestinationManager.shared.remove(type: FileLoggerDestination.self)
XCTAssertEqual(MELoggerDestinationManager.shared.getDestinations().count, 1)
}

func testConsoleLoggerDestination() {

let settings = ConsoleLoggerDestination.Settings(isEnabled: true)
Expand Down

0 comments on commit c10614c

Please sign in to comment.