Skip to content

fix(connlib): recreate log file if it got deleted#8926

Merged
thomaseizinger merged 5 commits intomainfrom
fix/recreate-logger-when-deleted
Apr 29, 2025
Merged

fix(connlib): recreate log file if it got deleted#8926
thomaseizinger merged 5 commits intomainfrom
fix/recreate-logger-when-deleted

Conversation

@thomaseizinger
Copy link
Member

Currently, when connlib's log file gets deleted, we write logs into nirvana until the corresponding process gets restarted. This is painful for users to do because they need to restart the IPC service or Network Extension. Instead, we can simply check if the log file exists prior to writing to it and re-create it if it doesn't.

Resolves: #6850
Related: #7569

@vercel
Copy link

vercel bot commented Apr 29, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
firezone ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 29, 2025 0:11am

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR addresses the issue where logs are lost when the current log file is deleted by adding a check to recreate the file before writing logs.

  • Adds file existence checking and file recreation logic in the Appender implementation.
  • Introduces tests to validate that the log file is correctly recreated after deletion.
  • Updates the clear_logs functionality in the headless-client to only target .log files.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
rust/logging/src/file.rs Implements re-creating the log file if it was deleted.
rust/logging/Cargo.toml Adds a dependency on tempfile for testing purposes.
rust/headless-client/src/clear_logs.rs Simplifies clearing logic to focus solely on .log files.

Comment on lines +123 to +124
if !std::fs::exists(self.directory.join(&filename)).unwrap_or_default() =>
{
Copy link

Copilot AI Apr 29, 2025

Choose a reason for hiding this comment

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

The use of unwrap_or_default() is incorrect as std::fs::exists returns a bool rather than a Result. Remove unwrap_or_default() to ensure the file existence is checked correctly.

Suggested change
if !std::fs::exists(self.directory.join(&filename)).unwrap_or_default() =>
{
if !std::fs::exists(self.directory.join(&filename)) =>

Copilot uses AI. Check for mistakes.
Copy link
Member Author

Choose a reason for hiding this comment

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

Go home Copilot, you are drunk.

@thomaseizinger thomaseizinger added this pull request to the merge queue Apr 29, 2025
Merged via the queue into main with commit 122d84c Apr 29, 2025
114 checks passed
@thomaseizinger thomaseizinger deleted the fix/recreate-logger-when-deleted branch April 29, 2025 13:25
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.

feat(rust/gui-client): roll over to new log file when clearing logs

3 participants