Skip to content

Commit

Permalink
Merge pull request #9 from immobiliare/feature/fix-transport-minimum-…
Browse files Browse the repository at this point in the history
…level

Fixed minimum transport accept level not accepting the minimum value
  • Loading branch information
malcommac authored Jan 29, 2024
2 parents 00e90c6 + 284b24a commit 20ba5cf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Glider/Sources/Log/Additional Structures/Level.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ extension Level {
return true
}

return self.rawValue < minLevel.rawValue
return self.rawValue <= minLevel.rawValue
}

#if os(iOS) || os(tvOS) || os(macOS)
Expand Down
4 changes: 4 additions & 0 deletions Tests/GliderTests/Core+Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,15 @@ final class CoreTests: XCTestCase {
/// so you can avoid to write all the messages on it even if logger accepts them.
func test_minimumTransportAcceptLevel() throws {
var minAcceptedLevel: Glider.Level? = .error
var passedCountWhenSet = 0
var passedCountWhenNil = 0

let transport = TestTransport { event, _ in
print("[\(event.level.description)] \(event.message)")

if let minAcceptedLevel = minAcceptedLevel {
XCTAssertTrue(event.level <= minAcceptedLevel)
passedCountWhenSet += 1
} else {
passedCountWhenNil += 1
}
Expand All @@ -85,6 +87,8 @@ final class CoreTests: XCTestCase {
log.error?.write(msg: "[SET] Should pass both")
log.critical?.write(msg: "[SET] Should pass both")

XCTAssertEqual(passedCountWhenSet, 2)

// ignore
transport.minimumAcceptedLevel = nil
minAcceptedLevel = nil
Expand Down

0 comments on commit 20ba5cf

Please sign in to comment.