Skip to content

Use file handle in TeeLogger#3515

Merged
koesie10 merged 3 commits intomainfrom
koesie10/tee-logger-file-handle
Apr 2, 2024
Merged

Use file handle in TeeLogger#3515
koesie10 merged 3 commits intomainfrom
koesie10/tee-logger-file-handle

Conversation

@koesie10
Copy link
Copy Markdown
Member

This switches the TeeLogger from using the appendFile function to manually opening and closing a file handle and calling appendFile on the file handle. This results in a more efficient implementation as the file handle is only opened once and closed once, instead of being opened and closed for every log message. This should result in less "too many open files" errors.

Checklist

  • CHANGELOG.md has been updated to incorporate all user visible changes made by this pull request.
  • Issues have been created for any UI or other user-facing changes made by this pull request.
  • [Maintainers only] If this pull request makes user-facing changes that require documentation changes, open a corresponding docs pull request in the github/codeql repo and add the ready-for-doc-review label there.

This switches the `TeeLogger` from using the `appendFile` function to
manually opening and closing a file handle and calling `appendFile` on
the file handle. This results in a more efficient implementation as the
file handle is only opened once and closed once, instead of being
opened and closed for every log message. This should result in less
"too many open files" errors.
@koesie10 koesie10 marked this pull request as ready for review March 26, 2024 15:14
@koesie10 koesie10 requested a review from a team as a code owner March 26, 2024 15:14
Comment thread extensions/ql-vscode/src/common/disposable-object.ts Outdated
Comment thread extensions/ql-vscode/src/local-queries/local-query-run.ts Outdated
Comment thread extensions/ql-vscode/src/common/logging/tee-logger.ts
// display and sorting might depend on the number of results
await this.queryHistoryManager.refreshTreeView();

if (isDisposable(this.logger)) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think the disposal of the logger is currently being done in all the right places. I was wondering whether it would be clearer and safer to make LocalQueryRun implement Disposable. I decided that I don't think it matters much. It would make some things more consistent but we'd hit a blocker in debugger-ui.ts and ultimately I'm not sure it brings any extra safety.

So overall I don't think anything needs to change. I just wanted to post my thoughts on it 🤷🏼

@koesie10 koesie10 requested a review from a team March 28, 2024 13:38
Copy link
Copy Markdown
Contributor

@robertbrignull robertbrignull left a comment

Choose a reason for hiding this comment

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

LGTM

@koesie10 koesie10 merged commit ff6f6cd into main Apr 2, 2024
@koesie10 koesie10 deleted the koesie10/tee-logger-file-handle branch April 2, 2024 08:02
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