Skip to content

Commit edafb12

Browse files
authored
Merge pull request #1760 from ahoppen/log-to-stdout
Make `logHandler` print to stdout instead of stderr
2 parents 431816a + 6fbddd4 commit edafb12

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Sources/SKLogging/NonDarwinLogging.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,12 @@ actor LogHandlerActor {
281281

282282
/// The handler that is called to log a message from `NonDarwinLogger` unless `overrideLogHandler` is set on the logger.
283283
@LogHandlerActor
284-
var logHandler: @Sendable (String) async -> Void = { fputs($0 + "\n", stderr) }
284+
var logHandler: @Sendable (String) async -> Void = { message in
285+
// Print to stdout. When using the sourcekit-lsp binary, we will have stdout redirected to stderr, so it ends up
286+
// logging to stderr. During test execution, we log to stdout, which is generally better handled than logging to
287+
// stderr by XCTest (for some reason logging to stderr will hang test execution when running tests in parallel).
288+
print(message + "\n")
289+
}
285290

286291
/// The queue on which we log messages.
287292
///

0 commit comments

Comments
 (0)