Skip to content

Add __android_log_is_loggable_len #6

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

Merged
merged 1 commit into from
Mar 4, 2025

Conversation

dextero
Copy link

@dextero dextero commented Feb 24, 2025

A variant of __android_log_is_loggable that allows passing non-null-terminated tag, avoiding the need for allocating a temporary buffer when called from android_logger.

The function is available since Android API 30 [1], the same as __android_log_write_log_message that's already present in the code.

[1] https://cs.android.com/android/platform/superproject/main/+/main:system/logging/liblog/include/android/log.h;l=358

A variant of __android_log_is_loggable that allows passing
non-null-terminated tag, avoiding the need for allocating a temporary
buffer when called from android_logger.

The function is available since Android API 30 [1], the same as
__android_log_write_log_message that's already present in the code.

[1] https://cs.android.com/android/platform/superproject/main/+/main:system/logging/liblog/include/android/log.h;l=358
@@ -13,6 +13,8 @@ pub type c_va_list = raw::c_void;
pub type c_int = raw::c_int;
#[allow(non_camel_case_types)]
pub type c_char = raw::c_char;
#[allow(non_camel_case_types)]
pub type c_size_t = raw::c_ulong;

// automatically generated by rust-bindgen
Copy link
Member

@MarijnS95 MarijnS95 Mar 4, 2025

Choose a reason for hiding this comment

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

On the side (unrelated to this PR), this doesn't sound very up-to-date :). There's no script or documentation explaining how to run bindgen to regenerate/update this file, and it's probably been edited by hand many times.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It's a bit awkward to have bindgen for android NDK (requires andoid NDK, which you can't ask every dev to install :)), unless it's separate from cargo build. Yes, it was done by hand, at least partially. In my defense, I thought these kinds of system definitions should not change, otherwise they would break downstream massively.

Copy link
Member

Choose a reason for hiding this comment

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

There's always the option to just run it once and check in the generated bindings - without modifying them by hand - that is exactly what I do for the ndk-sys crate 🙂

That way there is at least a reference describing how to exactly translate the bindings. Existing symbols shouldn't change - and I guess everyone hoped/expected the log API to stay very small - but adding new APIs becomes slightly more convenient.

Copy link
Member

Choose a reason for hiding this comment

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

#7 🎉

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for contributing with your knowledge :)

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.

3 participants