microsoft / mimalloc

mimalloc is a compact general purpose allocator with excellent performance.
MIT License
10.55k stars 856 forks source link

Output logs to logcat on android #927

Open nitanmarcel opened 2 months ago

nitanmarcel commented 2 months ago

Is there a way to make the logs (verbose/errors) also be printed to android logcat using something like __android_log_vprint ?

fouzul-hassan commented 2 months ago

the general approach you can take to integrate __android_log_vprint with mimalloc:

  1. Modify the Logging Code in mimalloc: You'll need to adjust the logging functions within the mimalloc source code to use __android_log_vprint when running on an Android platform. This can be done by checking for the Android environment using preprocessor macros.

  2. Include the Necessary Android Header: Ensure that the necessary Android headers are included for logging. Typically, this would mean including <android/log.h> in the relevant source files.

  3. Use Conditional Compilation: Use #ifdef or #if defined to conditionally compile code that uses __android_log_vprint only when building for Android.

nitanmarcel commented 2 months ago

the general approach you can take to integrate __android_log_vprint with mimalloc:

  1. Modify the Logging Code in mimalloc: You'll need to adjust the logging functions within the mimalloc source code to use __android_log_vprint when running on an Android platform. This can be done by checking for the Android environment using preprocessor macros.
  2. Include the Necessary Android Header: Ensure that the necessary Android headers are included for logging. Typically, this would mean including <android/log.h> in the relevant source files.
  3. Use Conditional Compilation: Use #ifdef or #if defined to conditionally compile code that uses __android_log_vprint only when building for Android.

I opened a PR a while ago that does this

https://github.com/microsoft/mimalloc/pull/928