Skip to content

Log to stderr instead of sending window/logMessage #327

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

Merged
merged 1 commit into from
Oct 7, 2020

Conversation

DavidGoldman
Copy link
Contributor

  • clangd itself already logs to stderr so sourcekit-lsp
    should do the same for consistency (unless we want to
    capture clangd's stderr and forward it in the LSP)

  • Editors such as VS Code will show stderr output in the same
    output channel where it shows logMessage + traces

- clangd itself already logs to stderr so sourcekit-lsp
  should do the same for consistency (unless we want to
  capture clangd's stderr and forward it in the LSP)

- Editors such as VS Code will show stderr output in the same
  output channel where it shows logMessage + traces

Change-Id: Iaf00cffa2e64d8490e21b49a3a9d34a17f54aa9f
@DavidGoldman
Copy link
Contributor Author

Let me know if you want me to change the time format or also include the logging level; was thinking of sending a follow up change to make requests/responses not logged by default but then log everything upon a debug log level just like clangd.

@DavidGoldman
Copy link
Contributor Author

@swift-ci please test

private func logImpl(_ message: String, level: LogLevel, usedOSLog: Bool) {

if !self.disableNSLog && !usedOSLog {
// Fallback to NSLog if os_log isn't available.
NSLog(message)
} else {
self.logToStderr(message, level: level)
Copy link
Contributor

Choose a reason for hiding this comment

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

I just checked: disableNSLog is never true except in unit tests. Should we just rely on NSLog?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm we could but won't that duplicate os_logs (os_log from us, NSLog)? If we drop our manual os_log. usage we could but it would be a slight change in behavior (filtering before logging)

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah sorry, I misread how it would work.

@benlangmuir benlangmuir merged commit 833b36c into swiftlang:main Oct 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants