Centralize desktop log infrastructure [WPB-27016]#9692
Open
screendriver wants to merge 8 commits into
Open
Conversation
Add Electron-independent helpers for constructing the existing log root, main-process log file, legacy webview directory, and SSO log file paths. Cover the legacy path formats with focused main-process tests. No runtime call sites or logging behavior change in this commit.
Read Electron’s current user-data directory whenever the main-process logger is created, so portable and custom user-data paths determine the log root. Add regression coverage proving the resolved log directory changes when Electron’s user-data path changes. No log files are written by the test.
Apply portable user-data configuration before main logger creation and resolve all main-process log paths through the logging helpers. Preserve the existing webview log directory format and startup behavior while removing duplicated path construction from main.ts.
Resolve the log root lazily for SSO console logging and account log deletion. Use shared path helpers while preserving the existing account log-file layout and deletion target.
Resolve the default log root lazily for discovery and export. Add temporary-directory regression coverage for nested .log and .old files, symbolic-link exclusion, relative and absolute results, and preserved export paths.
Move the existing startup .log-to-.old migration into the logging module. Keep main.ts focused on orchestration and add temporary-directory coverage for nested log migration while preserving existing .old files.
Avoid creating SSO, account-deletion, and log-export loggers during module initialization. This ensures their log paths are resolved only after portable or custom user-data configuration has taken effect.
|
|
Semgrep found 12
Detected possible user input going into a View Dataflow Graphflowchart LR
classDef invis fill:white, stroke: none
classDef default fill:#e7f5ff, color:#1c7fd6, stroke: none
subgraph File0["<b>electron/src/logging/loggerUtils.ts</b>"]
direction LR
%% Source
subgraph Source
direction LR
v0["<a href=https://github.com/wireapp/wire-desktop/blob/bc1bfe54974d78e3beca0c1765a2d396ad9a8f94/electron/src/logging/loggerUtils.ts#L34 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 34] base</a>"]
end
%% Intermediate
subgraph Traces0[Traces]
direction TB
v2["<a href=https://github.com/wireapp/wire-desktop/blob/bc1bfe54974d78e3beca0c1765a2d396ad9a8f94/electron/src/logging/loggerUtils.ts#L34 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 34] base</a>"]
v3["<a href=https://github.com/wireapp/wire-desktop/blob/bc1bfe54974d78e3beca0c1765a2d396ad9a8f94/electron/src/logging/loggerUtils.ts#L41 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 41] getLogFilenames</a>"]
v4["<a href=https://github.com/wireapp/wire-desktop/blob/bc1bfe54974d78e3beca0c1765a2d396ad9a8f94/electron/src/logging/loggerUtils.ts#L41 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 41] relativeFilePaths</a>"]
v5["<a href=https://github.com/wireapp/wire-desktop/blob/bc1bfe54974d78e3beca0c1765a2d396ad9a8f94/electron/src/logging/loggerUtils.ts#L43 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 43] of</a>"]
v6["<a href=https://github.com/wireapp/wire-desktop/blob/bc1bfe54974d78e3beca0c1765a2d396ad9a8f94/electron/src/logging/loggerUtils.ts#L43 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 43] relativeFilePath</a>"]
end
v2 --> v3
v3 --> v4
v4 --> v5
v5 --> v6
%% Sink
subgraph Sink
direction LR
v1["<a href=https://github.com/wireapp/wire-desktop/blob/bc1bfe54974d78e3beca0c1765a2d396ad9a8f94/electron/src/logging/loggerUtils.ts#L44 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 44] relativeFilePath</a>"]
end
end
%% Class Assignment
Source:::invis
Sink:::invis
Traces0:::invis
File0:::invis
%% Connections
Source --> Traces0
Traces0 --> Sink
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Problem
Desktop logging responsibilities are currently spread across the Electron main process, the logger factory, SSO logging, log export, and account deletion.
Several modules construct their own paths below
app.getPath('userData'). Some of these paths are resolved during module initialization, before portable mode or--user_data_dircan update Electron's final user-data location.This duplication makes the logging lifecycle difficult to understand and makes subsequent rotation and retention changes unnecessarily risky.
Intent
Create one explicit boundary for desktop log paths and filesystem operations without changing the existing logging behavior.
This pull request prepares the codebase for later changes to restart handling, rotation, retention, and directory organization.