Skip to content

Commit f531269

Browse files
authored
Fix deprecation warnings around default log implementations on handlers (#310)
Motivation: Latest swift introduces new warnings when deprecated default implementations are used. Modifications: Add new log implementation to NoopLogHandler. Mark test of old method as deprecated to silence warning. Result: Warning free builds on latest swift 6 compiler.
1 parent 6553ef5 commit f531269

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

Sources/Logging/Logging.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,6 +1276,14 @@ public struct SwiftLogNoOpLogHandler: LogHandler {
12761276

12771277
@inlinable public func log(level: Logger.Level, message: Logger.Message, metadata: Logger.Metadata?, file: String, function: String, line: UInt) {}
12781278

1279+
public func log(level: Logger.Level,
1280+
message: Logger.Message,
1281+
metadata: Logger.Metadata?,
1282+
source: String,
1283+
file: String,
1284+
function: String,
1285+
line: UInt) {}
1286+
12791287
@inlinable public subscript(metadataKey _: String) -> Logger.Metadata.Value? {
12801288
get {
12811289
return nil

Tests/LoggingTests/CompatibilityTest.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import XCTest
1717

1818
final class CompatibilityTest: XCTestCase {
19+
@available(*, deprecated, message: "Testing deprecated functionality")
1920
func testAllLogLevelsWorkWithOldSchoolLogHandlerWorks() {
2021
let testLogging = OldSchoolTestLogging()
2122

@@ -45,6 +46,7 @@ private struct OldSchoolTestLogging {
4546
private let _config = Config() // shared among loggers
4647
private let recorder = Recorder() // shared among loggers
4748

49+
@available(*, deprecated, message: "Testing deprecated functionality")
4850
func make(label: String) -> any LogHandler {
4951
return OldSchoolLogHandler(label: label,
5052
config: self.config,
@@ -57,6 +59,7 @@ private struct OldSchoolTestLogging {
5759
var history: some History { return self.recorder }
5860
}
5961

62+
@available(*, deprecated, message: "Testing deprecated functionality")
6063
private struct OldSchoolLogHandler: LogHandler {
6164
var label: String
6265
let config: Config

0 commit comments

Comments
 (0)