Skip to content

Write log messages to files on non-Darwin platforms #1411

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
Jun 5, 2024

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Jun 3, 2024

Instead of logging to stderr, write log messages to files in /var/log/sourcekit-lsp/sourcekit-lsp-<pid>.log.

This allows us to retrieve the log messages from sourcekit-lsp diagnose.

Fixes #1286
rdar://127138318

@ahoppen ahoppen requested review from bnbarham and hamishknight June 3, 2024 19:58
@ahoppen ahoppen requested a review from benlangmuir as a code owner June 3, 2024 19:58
@ahoppen
Copy link
Member Author

ahoppen commented Jun 3, 2024

@swift-ci Please test

@ahoppen ahoppen changed the title Write log messages to files on Linux 🚥 #1410 Write log messages to files on Linux Jun 4, 2024
@ahoppen
Copy link
Member Author

ahoppen commented Jun 4, 2024

I re-wrote the implementation quite a bit based on feedback from @bnbarham to roll through 10 log files of 5MB each instead of truncating one log file in place since it reduces the number of bytes that need to be written (in the old implementation we needed to write 4MB every time we trimmed the start of the log).

@ahoppen
Copy link
Member Author

ahoppen commented Jun 4, 2024

@swift-ci Please test

@ahoppen
Copy link
Member Author

ahoppen commented Jun 5, 2024

@swift-ci Please test Windows

Comment on lines 76 to 77
/// Occasionally check if the log file exceeds the target log size. If this is the case, truncate the beginning of the
/// log to reduce the log size.
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess you could also say that the logs will be rotated if logRotateCount > 1

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, this comment is just completely outdated.

Instead of logging to `stderr`, write log messages to files in `.sourcekit-lsp/logs/sourcekit-lsp-<pid>.<log index>.log`.

This allows us to retrieve the log messages from `sourcekit-lsp diagnose`.

Fixes swiftlang#1286
rdar://127138318
@ahoppen ahoppen changed the title Write log messages to files on Linux Write log messages to files on non-Darwin platforms Jun 5, 2024
@ahoppen
Copy link
Member Author

ahoppen commented Jun 5, 2024

@swift-ci Please test

@ahoppen
Copy link
Member Author

ahoppen commented Jun 5, 2024

@swift-ci Please test Windows

@ahoppen ahoppen merged commit 6f7bffa into swiftlang:main Jun 5, 2024
3 checks passed
@ahoppen ahoppen deleted the log-to-file branch June 5, 2024 20:34
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.

Log to syslog on Linux
2 participants