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

bevy_log: Use os_log on iOS #4462

Closed
wants to merge 3 commits into from

Conversation

HackerFoo
Copy link
Contributor

@HackerFoo HackerFoo commented Apr 12, 2022

Objective

On mobile devices, it's best to use the OS's native logging due to the difficulty of accessing the console. This is already done for Android.

Solution

This PR uses Absolucy's tracing-oslog (ZLib license) for iOS in order to use Apple's os_log.

Changelog

  • Change bevy_log to use Apple's os_log on iOS.

@github-actions github-actions bot added the S-Needs-Triage This issue needs to be labelled label Apr 12, 2022
@alice-i-cecile alice-i-cecile added O-iOS Specific to the iOS mobile operating system A-Log and removed S-Needs-Triage This issue needs to be labelled labels Apr 12, 2022
Copy link
Contributor

@IceSentry IceSentry left a comment

Choose a reason for hiding this comment

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

I don't have a way to test it but the code looks good to me other than that.

@cart cart added A-Diagnostics Logging, crash handling, error reporting and performance analysis and removed A-Log labels Jun 1, 2022
Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

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

I'm going to merge this optimistically; @HackerFoo please open a new issue or PR if you run into problems on iOS.

The code itself is good and well explained.

bors r+

@bors
Copy link
Contributor

bors bot commented Oct 10, 2022

Merge conflict.

@james7132
Copy link
Member

@HackerFoo sorry for dropping the ball on this, could you update this PR?

@james7132 james7132 added this to the 0.11 milestone Mar 16, 2023
@alice-i-cecile alice-i-cecile added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Jun 19, 2023
@alice-i-cecile
Copy link
Member

Ping @HackerFoo: I'm leaving this in the milestone because it seems like the merge conflict should be easy.

@github-actions
Copy link
Contributor

You added a new example but didn't add metadata for it. Please update the root Cargo.toml file.

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
@cart
Copy link
Member

cart commented Jun 22, 2023

Hmm multiple new conflicting build deps (due to an older version of bindgen). Not as bad as non-build deps, but also not great.

@alice-i-cecile
Copy link
Member

@alice 🌹 Here’s a newer version. I’ll try to update the PR if I can: HackerFoo@b97063d

@alice-i-cecile alice-i-cecile removed the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Jun 26, 2023
@alice-i-cecile alice-i-cecile removed this from the 0.11 milestone Jun 26, 2023
@alice-i-cecile alice-i-cecile added the S-Adopt-Me The original PR author has no intent to complete this work. Pick me up! label Jun 26, 2023
@alice-i-cecile
Copy link
Member

I don't have the setup or expertise to validate this independently: adding Adopt-Me in the hopes that someone who does can chip in :)

@therealbnut
Copy link
Contributor

therealbnut commented May 14, 2024

@alice-i-cecile Hi, I thought this "S-Adopt-Me" PR would be a good first simple Bevy contribution. I've merged the latest main and made some changes to get it working. I've also tested it on an iOS device and it works as I believe it's expected to.

This is my branch: https://github.com/therealbnut/bevy/tree/use-oslog-for-ios

I believe I've preserved the PR's orignal intent after the merge conflict, but as the code is changed and simplified now it may be worth a quick look to check I haven't removed something by mistake.

It's also worth noting that the dependency this adds hasn't had bug fixes released in a few years, so we may want to consider one or more of:

  1. a feature flag to opt-in, and it would also allow os_log on MacOS
  2. merge as-is and have some (minor?) upstream bugs
  3. hold off on this PR until a suitable alternative dependency arises
  4. maintain our own implementation

Future work

In a follow-up PR it might be good to make the subsystem field have a better default value, like this one. That value can be retrieved programmatically if we bind another system API (Bundle.main.bundleIdentifier in Swift, or the C/ObjC equivalent for posterity). This would almost always be the correct value, while the current default is unlikely to ever be correct.

@alice-i-cecile
Copy link
Member

Fantastic stuff: can you open a PR with those comments in a Questions for Reviewers section? I'll respond to your questions there, so the answers don't get lost. I'm in favor of a merge-as-incremental-improvement strategy, but I agree with your concerns about dead dependencies and have ideas to address that.

@therealbnut therealbnut mentioned this pull request May 14, 2024
@therealbnut
Copy link
Contributor

can you open a PR with those comments in a Questions for Reviewers section

Thanks @alice-i-cecile, I've made that PR here, I hope that's what you meant.

@richchurcher
Copy link
Contributor

Closing in favour of #13364.

@therealbnut
Copy link
Contributor

@richchurcher thanks for the reminder, my PR on the third-party library blocking #13364 was finally merged, so hopefully that fixes the security advisories

github-merge-queue bot pushed a commit that referenced this pull request Oct 11, 2024
# Objective

On mobile devices, it's best to use the OS's native logging due to the
difficulty of accessing the console. This is already done for Android.

This is an updated version of
#4462.

## Solution

This PR uses Absolucy's
[tracing-oslog](https://github.com/Absolucy/tracing-oslog) ([ZLib
license](https://github.com/Absolucy/tracing-oslog/blob/main/LICENSE.md))
for iOS in order to use Apple's `os_log`.

## Testing

I ran `examples/mobile` with the logging from `examples/app/logs.rs` on
an iOS device, I then checked the logs could be filtered in the MacOS
Console.app.

## Changelog

 - Change bevy_log to use Apple's os_log on iOS.

## Questions for Reviewers
It's worth noting that the dependency this adds hasn't had bug fixes
released in a few years, so we may want to consider one or more of:
 1. a feature flag to opt-in, and it would also allow `os_log` on MacOS
 2. merge as-is and have some (minor?) upstream bugs
 3. hold off on this PR until a suitable alternative dependency arises
 4. maintain our own implementation

## Future work

In a follow-up PR it might be good to make the `subsystem` field have a
better default value, like [this
one](https://github.com/bevyengine/bevy/blob/main/examples/mobile/bevy_mobile_example.xcodeproj/project.pbxproj#L363).
That value can be retrieved programmatically if we bind another system
API (For posterity in Swift this is `Bundle.main.bundleIdentifier`, but
the C/ObjC equivalent is likely easier to bind). This would almost
always be the correct value, while the current default is unlikely to
ever be correct.

---------

Co-authored-by: Dusty DeWeese <dustin.deweese@gmail.com>
Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
Co-authored-by: Carter Anderson <mcanders1@gmail.com>
Co-authored-by: François Mockers <francois.mockers@vleue.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Diagnostics Logging, crash handling, error reporting and performance analysis O-iOS Specific to the iOS mobile operating system S-Adopt-Me The original PR author has no intent to complete this work. Pick me up!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants