Skip to content

Commit 9276b3a

Browse files
committed
Log to stderr as well as the log file, on non-Darwin platforms
This is consistent with other LSP servers, and makes debugging sourcekit-lsp easier.
1 parent 3f1568c commit 9276b3a

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Sources/SKLogging/NonDarwinLogging.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,11 @@ package struct NonDarwinLogger: Sendable {
346346
// sourcekitd response). 10.000 characters was chosen because it seems to fit the result of most sourcekitd
347347
// responses that are not generated interface or global completion results (which are a lot bigger).
348348
var message = message().value.string(for: self.privacyLevel)
349+
350+
// In addition to writing to the log file, also log to stderr, so LSP output is visible in the editor
351+
// (e.g. VS Code's Output panel).
352+
fputs(message + "\n", stderr)
353+
349354
if message.utf8.count > 10_000 {
350355
// Check for UTF-8 byte length first because that's faster since it doesn't need to count UTF-8 characters.
351356
// Truncate using `.prefix` to avoid cutting of in the middle of a UTF-8 multi-byte character.

0 commit comments

Comments
 (0)