Skip to content
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

VPN-6041: Add Swift logs from app #9192

Merged
merged 11 commits into from
Mar 19, 2024
Merged

VPN-6041: Add Swift logs from app #9192

merged 11 commits into from
Mar 19, 2024

Conversation

mcleinman
Copy link
Collaborator

Description

We've had a problem for a while where only the Swift logs from the network extension are included in the log file output by the app.

Ideally, the swift logs would be inline with the rest of the app logs (from C++ land). I looked into adding a objc bridging header and writing directly to the main logger. Unfortunately, the main logger class uses a lot of Qt imports, and the build fails due to these deeper dependencies. After I did that research, I went with this approach - a somewhat hacky fix. (Given that untangling this would be non-trivial and the current status of the app, I went with a simpler solution.)

I've added a third section of logs to the log output - Swift logs from the main app will exist, but be in their own section. This is done by hackily appending the Swift log section to the backend logs, so it looks no different to the main app. Where possible, I maintained the same code patterns that existed for the backend (network extension) logs.

I had to update our calls from C++ to iOS logging - you'll notice updates to functions with names like errorToConsoleWithMessage. Without this, the C++ app logs were logged in two places - the main app logs (as expected) and these new Swift logs. This is because we were sending all C++ logs to Swift-land - but seemingly only to log them to the console. The easiest way in the Swift logging class to separate out "C++ logs to print to console only" and "Swift logs to print to console and to save to disk" was to give those C++ logs their own functions, which is done as part of this PR.

Sample logs from a fresh run of the app

Reference

VPN-6041

Checklist

  • My code follows the style guidelines for this project
  • I have not added any packages that contain high risk or unknown licenses (GPL, LGPL, MPL, etc. consult with DevOps if in question)
  • I have performed a self review of my own code
  • I have commented my code PARTICULARLY in hard to understand areas
  • I have added thorough tests where needed

@mcleinman mcleinman requested a review from brizental March 13, 2024 17:31
src/platforms/ios/ioslogger.swift Outdated Show resolved Hide resolved
src/platforms/ios/ioslogger.swift Outdated Show resolved Hide resolved
@mcleinman
Copy link
Collaborator Author

@lesleyjanenorton per our discussion, I made a few small edits. I also looked at all the Swift logs - I couldn't find any that include superfluous names/data, and none that include IP addresses or anything like that.

@mcleinman mcleinman merged commit 162e1b9 into main Mar 19, 2024
129 checks passed
@mcleinman mcleinman deleted the vpn-6041-ios-swift-logging branch March 19, 2024 15:30
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