Skip to content

Commit

Permalink
Add support for interpolating errors in no-op log messages
Browse files Browse the repository at this point in the history
  • Loading branch information
d-ronnqvist committed Dec 3, 2024
1 parent 66dd6bf commit ac8a510
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ package struct NoOpLogMessage: ExpressibleByStringInterpolation, ExpressibleBySt
package mutating func appendInterpolation(_ number: @autoclosure @escaping () -> Float, format: NoOpLogFloatFormatting = .fixed, align: NoOpLogStringAlignment = .none, privacy: NoOpLogPrivacy = .auto) {}
package mutating func appendInterpolation(_ number: @autoclosure @escaping () -> Double, format: NoOpLogFloatFormatting = .fixed, align: NoOpLogStringAlignment = .none, privacy: NoOpLogPrivacy = .auto) {}

// Append errors
package mutating func appendInterpolation(_ error: @autoclosure @escaping () -> any Error, privacy: NoOpLogPrivacy = .auto, attributes: String = "") {}
package mutating func appendInterpolation(_ error: @autoclosure @escaping () -> (any Error)?, privacy: NoOpLogPrivacy = .auto, attributes: String = "") {}

// Add more interpolations here as needed
}

Expand Down
2 changes: 2 additions & 0 deletions Tests/SwiftDocCTests/Utility/NoOpSignposterShimTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,7 @@ final class NoOpSignposterShimTests: XCTestCase {

logger.log(level: .default, "Some aligned values \(12, align: .right(columns: 5)) \("some text", align: .left(columns: 10))")

struct SomeError: Swift.Error {}
logger.error("Some error \(SomeError())")
}
}

0 comments on commit ac8a510

Please sign in to comment.