Skip to content

Fix three activity log problems - #26283

Merged
jkmassel merged 1 commit into
trunkfrom
issue-26282
Oct 30, 2026
Merged

jkmassel merged 1 commit into
trunkfrom
issue-26282

Conversation

@jkmassel

@jkmassel jkmassel commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #26277. Merge that first; GitHub will then retarget this PR to trunk.

Fixes the three activity log problems listed in #26282. All three are on trunk. None comes from #26277.

Changes

1. "Delete Logs" now deletes every log

The Activity Logs alert says "Are you sure you want to delete all activity logs?", but the button deleted only the older files. It then cleared the list without reloading it. The list looked empty, and the next visit showed the old "Current" log again.

  • SupportActivityLogView.swift: call deleteAllLogs(), as the alert promises. This matches the new support screen's "Delete all Logs" and sign-out. The list then reloads from LogFileStore.
  • WPLogger.h/.m: remove deleteArchivedLogs, which nothing else uses.

CocoaLumberjack notices that its open file was deleted and starts a new one. Reopening the screen still shows a "Current" row, but that file now starts with the "All log files erased." line.

2. One unreadable file no longer fails the log list

SupportDataProvider.swift: WpLogDataProvider skips files it can't read. Before, the whole list failed if a file disappeared between listing the folder and reading its details. This was found by reading the code. We did not reproduce it in the app; a unit test covers it.

3. Crash reports attach the log from the time of the crash

EventLoggingDataProvider.swift: logFilePath(forErrorLevel:at:) now returns the newest file created at or before the event's timestamp. Before, it always returned the newest file. A crash is sent on the next launch, and that launch may already have started a new file. If no file has a creation date, it falls back to the newest file. Events sent now (non-fatal events, the Zendesk log upload) still get the newest file, as before.

Test plan

  • New Swift Testing suites in LogFileTests.swift: Test run with 5 tests in 2 suites passed.
  • After stacking on Read log files through LogFileStore instead of CocoaLumberjack #26277, the new suites plus Read log files through LogFileStore instead of CocoaLumberjack #26277's LogFileStoreTests: Test run with 8 tests in 3 suites passed. The simulator checks below ran before stacking. Stacking changed only how the files are listed (AppLogFile from LogFileStore), not the fixes.
    • EventLoggingDataProviderTests covers the crash-time file, the newest file for the current session, the fallback, and no files at all.
    • WpLogDataProviderTests covers a file that no longer exists.
  • SwiftLint passes on the changed Swift files.
  • Activity Logs screen on an iOS 27.0 simulator (WordPress app), with 4 older log files added to Library/Caches/Logs. A temporary launch argument opened the screen directly and was not committed.
Before deleting Reopened after deleting Opening "Current"
Activity Logs list with the current log and four older logs Activity Logs list showing only a new current log The new current log starts with All log files erased

Files in Library/Caches/Logs after confirming Delete Logs:

Build Files left
Old delete path the current log (5,705 bytes, its old contents) ❌
This PR one new 46-byte log, containing only "All log files erased." ✅
  • The crash-log choice in a real crash (Jetpack app, iOS 27.0 simulator, -force-crash-logging YES). A temporary launch argument wrote a marker line to the log and then crashed. A temporary NSLog printed the file this PR picks and the file the old code would pick. Neither is committed.
Scenario Crash event time This PR attaches Old code would attach
A: the relaunch keeps writing to the same log (the usual case) 01:40:33 the file with the crash ✅ the same file ✅
B: the relaunch starts a new log file 01:41:23 the file with the crash (created 01:38:43) ✅ the new file (created 01:41:31), which has no crash ❌

In both runs, Sentry's crash event carried the crash time, and the chosen log uploaded (Finished uploading encrypted log). For B, the crashed file was marked archived before the relaunch to force a new file. That is what happens when the logger rolls over at launch.

Closes #26282.

@jkmassel jkmassel self-assigned this Oct 29, 2026
@jkmassel jkmassel modified the milestones: 27.6, 27.5 Oct 29, 2026
@jkmassel
jkmassel marked this pull request as ready for review October 29, 2026 01:31
@jkmassel
jkmassel requested a review from crazytonyli October 29, 2026 01:44
@jkmassel
jkmassel changed the base branch from trunk to jkmassel/26258-next-steps October 29, 2026 01:51
Base automatically changed from jkmassel/26258-next-steps to trunk October 29, 2026 21:02
@crazytonyli

Copy link
Copy Markdown
Contributor

@jkmassel This PR has conflicts.

- "Delete Logs" on the Activity Logs screen now deletes every log file, as
  its alert says, and reloads the list from disk. Removes the now-unused
  `deleteArchivedLogs`.
- The new support screen skips log files it can't read instead of failing
  the whole list.
- Crash reports attach the log file that was being written at the time of
  the event, instead of always the newest one.
@jkmassel

Copy link
Copy Markdown
Contributor Author

Sorry about that, fixed!

@jkmassel
jkmassel added this pull request to the merge queue Oct 30, 2026
Merged via the queue into trunk with commit e11abe6 Oct 30, 2026
21 checks passed
@jkmassel
jkmassel deleted the issue-26282 branch October 30, 2026 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Activity logs: follow-ups from the LogFileStore review (#26277)

2 participants