Skip to content

Log to stderr as well as the log file, on non-Darwin platforms #2155

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Sources/SKLogging/SetGlobalLogFileHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ private func logToFile(message: String, logDirectory: URL, logFileMaxBytes: Int,
private func setUpGlobalLogFileHandlerImpl(logFileDirectory: URL, logFileMaxBytes: Int, logRotateCount: Int) {
logHandler = { @LogHandlerActor message in
do {
// In addition to writing to the log file, also log to stderr, so LSP output is visible in the editor
// (e.g. VS Code's Output panel).
fputs(message + "\n", stderr)

Comment on lines +119 to +122
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost LGTM :). But now that we're printing this to stderr as well, I think we can remove the \(message) from the fputs below when the write to the log fails.

try logToFile(
message: message,
logDirectory: logFileDirectory,
Expand Down