Skip to content

Commit

Permalink
Fix deprecation warnings around default log implementations on handle…
Browse files Browse the repository at this point in the history
…rs (#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.
  • Loading branch information
PeterAdams-A authored Jun 19, 2024
1 parent 6553ef5 commit f531269
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Sources/Logging/Logging.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1276,6 +1276,14 @@ public struct SwiftLogNoOpLogHandler: LogHandler {

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

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

@inlinable public subscript(metadataKey _: String) -> Logger.Metadata.Value? {
get {
return nil
Expand Down
3 changes: 3 additions & 0 deletions Tests/LoggingTests/CompatibilityTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import XCTest

final class CompatibilityTest: XCTestCase {
@available(*, deprecated, message: "Testing deprecated functionality")
func testAllLogLevelsWorkWithOldSchoolLogHandlerWorks() {
let testLogging = OldSchoolTestLogging()

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

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

@available(*, deprecated, message: "Testing deprecated functionality")
private struct OldSchoolLogHandler: LogHandler {
var label: String
let config: Config
Expand Down

0 comments on commit f531269

Please sign in to comment.