Skip to content

Commit 9c6f0d5

Browse files
committed
remove redundant log level filtering
1 parent abc21c7 commit 9c6f0d5

File tree

3 files changed

+2
-32
lines changed

3 files changed

+2
-32
lines changed

3rd-party-integrations/SentrySwiftyBeaver/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ log.info("User logged in", context: ["userId": "12345", "sessionId": "abc"])
3939

4040
### Log Level Threshold
4141

42-
Set the minimum log level for messages to be sent to Sentry using SwiftyBeaver's built-in `minLevel` property. Messages below the configured threshold will be filtered out and not sent to Sentry.
42+
SwiftyBeaver automatically filters log messages based on each destination's `minLevel` property. Set `minLevel` to control which messages are sent to Sentry.
4343

4444
```swift
4545
let sentryDestination = SentryDestination()
46-
sentryDestination.minLevel = .info
46+
sentryDestination.minLevel = .error
4747
log.addDestination(sentryDestination)
4848
```
4949

3rd-party-integrations/SentrySwiftyBeaver/Sources/SentryDestination.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,6 @@ public class SentryDestination: BaseDestination {
6868
line: Int,
6969
context: Any? = nil
7070
) -> String? {
71-
// Additional guard for level filtering.
72-
guard level.rawValue >= minLevel.rawValue else {
73-
return nil
74-
}
7571
var attributes: [String: Any] = [:]
7672
attributes["sentry.origin"] = "auto.logging.swiftybeaver"
7773
attributes["swiftybeaver.level"] = "\(level.rawValue)"

3rd-party-integrations/SentrySwiftyBeaver/Tests/SentryDestinationTests.swift

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -215,30 +215,4 @@ final class SentryDestinationTests: XCTestCase {
215215
XCTAssertNotNil(log.attributes["swiftybeaver.context"])
216216
XCTAssertEqual(log.attributes["swiftybeaver.context"]?.value as? String, "simple string context")
217217
}
218-
219-
func testIntegration_MinLevelWarning_CapturesWarningAndAbove() throws {
220-
let sut = SentryDestination()
221-
sut.minLevel = .warning
222-
223-
// Log messages below the threshold (should be filtered out)
224-
_ = sut.send(.verbose, msg: "Verbose message", thread: "main", file: "Test.swift", function: "testFunction", line: 1)
225-
_ = sut.send(.debug, msg: "Debug message", thread: "main", file: "Test.swift", function: "testFunction", line: 2)
226-
_ = sut.send(.info, msg: "Info message", thread: "main", file: "Test.swift", function: "testFunction", line: 3)
227-
228-
// Log messages at or above the threshold
229-
_ = sut.send(.warning, msg: "Warning message", thread: "main", file: "Test.swift", function: "testFunction", line: 4)
230-
_ = sut.send(.error, msg: "Error message", thread: "main", file: "Test.swift", function: "testFunction", line: 5)
231-
_ = sut.send(.critical, msg: "Critical message", thread: "main", file: "Test.swift", function: "testFunction", line: 6)
232-
233-
XCTAssertEqual(capturedLogs.count, 3, "Expected all logs at or above .warning to be captured")
234-
let expectedLogs: [(body: String, level: SentryLog.Level)] = [
235-
("Warning message", .warn),
236-
("Error message", .error),
237-
("Critical message", .fatal)
238-
]
239-
for (index, expected) in expectedLogs.enumerated() {
240-
XCTAssertEqual(capturedLogs[index].body, expected.body)
241-
XCTAssertEqual(capturedLogs[index].level, expected.level)
242-
}
243-
}
244218
}

0 commit comments

Comments
 (0)