@@ -45,7 +45,7 @@ public enum LogConfig {
45
45
///
46
46
/// For documentation of the different log levels see
47
47
/// https://developer.apple.com/documentation/os/oslogtype.
48
- public enum NonDarwinLogLevel : Comparable , CustomStringConvertible {
48
+ public enum NonDarwinLogLevel : Comparable , CustomStringConvertible , Sendable {
49
49
case debug
50
50
case info
51
51
case `default`
@@ -102,7 +102,7 @@ public enum NonDarwinLogLevel: Comparable, CustomStringConvertible {
102
102
///
103
103
/// For documentation of the different privacy levels see
104
104
/// https://developer.apple.com/documentation/os/oslogprivacy.
105
- public enum NonDarwinLogPrivacy : Comparable {
105
+ public enum NonDarwinLogPrivacy : Comparable , Sendable {
106
106
case `public`
107
107
case `private`
108
108
case sensitive
@@ -132,16 +132,16 @@ public enum NonDarwinLogPrivacy: Comparable {
132
132
/// sourcekit-lsp.
133
133
///
134
134
/// This is used on platforms that don't have OSLog.
135
- public struct NonDarwinLogInterpolation : StringInterpolationProtocol {
136
- private enum LogPiece {
135
+ public struct NonDarwinLogInterpolation : StringInterpolationProtocol , Sendable {
136
+ private enum LogPiece : Sendable {
137
137
/// A segment of the log message that will always be displayed.
138
138
case string( String )
139
139
140
140
/// A segment of the log message that might need to be redacted if the
141
141
/// privacy level is lower than `privacy`.
142
142
case possiblyRedacted(
143
- description: ( ) -> String ,
144
- redactedDescription: ( ) -> String ,
143
+ description: @ Sendable ( ) -> String ,
144
+ redactedDescription: @ Sendable ( ) -> String ,
145
145
privacy: NonDarwinLogPrivacy
146
146
)
147
147
}
@@ -158,8 +158,8 @@ public struct NonDarwinLogInterpolation: StringInterpolationProtocol {
158
158
}
159
159
160
160
private mutating func append(
161
- description: @autoclosure @escaping ( ) -> String ,
162
- redactedDescription: @autoclosure @escaping ( ) -> String ,
161
+ description: @autoclosure @escaping @ Sendable ( ) -> String ,
162
+ redactedDescription: @autoclosure @escaping @ Sendable ( ) -> String ,
163
163
privacy: NonDarwinLogPrivacy
164
164
) {
165
165
if privacy == . public {
@@ -181,13 +181,15 @@ public struct NonDarwinLogInterpolation: StringInterpolationProtocol {
181
181
}
182
182
183
183
@_disfavoredOverload // Prefer to use the StaticString overload when possible.
184
- public mutating func appendInterpolation( _ message: CustomStringConvertible , privacy: NonDarwinLogPrivacy = . private)
185
- {
184
+ public mutating func appendInterpolation(
185
+ _ message: some CustomStringConvertible & Sendable ,
186
+ privacy: NonDarwinLogPrivacy = . private
187
+ ) {
186
188
append ( description: message. description, redactedDescription: " <private> " , privacy: privacy)
187
189
}
188
190
189
191
public mutating func appendInterpolation(
190
- _ message: CustomLogStringConvertibleWrapper ,
192
+ _ message: some CustomLogStringConvertibleWrapper & Sendable ,
191
193
privacy: NonDarwinLogPrivacy = . private
192
194
) {
193
195
append ( description: message. description, redactedDescription: message. redactedDescription, privacy: privacy)
@@ -198,7 +200,7 @@ public struct NonDarwinLogInterpolation: StringInterpolationProtocol {
198
200
}
199
201
200
202
/// Builds the string that represents the log message, masking all interpolation
201
- /// segments whose privacy level is greater thatn `logPrivacyLevel`.
203
+ /// segments whose privacy level is greater that `logPrivacyLevel`.
202
204
fileprivate func string( for logPrivacyLevel: NonDarwinLogPrivacy ) -> String {
203
205
var result = " "
204
206
for piece in pieces {
@@ -221,7 +223,7 @@ public struct NonDarwinLogInterpolation: StringInterpolationProtocol {
221
223
/// sourcekit-lsp.
222
224
///
223
225
/// This is used on platforms that don't have OSLog.
224
- public struct NonDarwinLogMessage : ExpressibleByStringInterpolation , ExpressibleByStringLiteral {
226
+ public struct NonDarwinLogMessage : ExpressibleByStringInterpolation , ExpressibleByStringLiteral , Sendable {
225
227
fileprivate let value : NonDarwinLogInterpolation
226
228
227
229
public init ( stringInterpolation: NonDarwinLogInterpolation ) {
@@ -257,12 +259,12 @@ private let loggingQueue: DispatchQueue = DispatchQueue(label: "loggingQueue", q
257
259
///
258
260
/// This logger is used to log messages to stderr on platforms where OSLog is
259
261
/// not available.
260
- public struct NonDarwinLogger {
262
+ public struct NonDarwinLogger : Sendable {
261
263
private let subsystem : String
262
264
private let category : String
263
265
private let logLevel : NonDarwinLogLevel
264
266
private let privacyLevel : NonDarwinLogPrivacy
265
- private let logHandler : ( String ) -> Void
267
+ private let logHandler : @ Sendable ( String ) -> Void
266
268
267
269
/// - Parameters:
268
270
/// - subsystem: See os.Logger
@@ -277,7 +279,7 @@ public struct NonDarwinLogger {
277
279
category: String ,
278
280
logLevel: NonDarwinLogLevel ? = nil ,
279
281
privacyLevel: NonDarwinLogPrivacy ? = nil ,
280
- logHandler: @escaping ( String ) -> Void = { fputs ( $0 + " \n " , stderr) }
282
+ logHandler: @escaping @ Sendable ( String ) -> Void = { fputs ( $0 + " \n " , stderr) }
281
283
) {
282
284
self . subsystem = subsystem
283
285
self . category = category
@@ -292,7 +294,7 @@ public struct NonDarwinLogger {
292
294
/// program to finish as quickly as possible.
293
295
public func log(
294
296
level: NonDarwinLogLevel ,
295
- _ message: @autoclosure @escaping ( ) -> NonDarwinLogMessage
297
+ _ message: @autoclosure @escaping @ Sendable ( ) -> NonDarwinLogMessage
296
298
) {
297
299
guard level >= self . logLevel else { return }
298
300
let date = Date ( )
0 commit comments