Skip to content

Support Android NDK ? #93

Closed
Closed

Description

@ascorbic-acid

Thanks for this great tool, im wondering if we can use it with Android, below is how we log in android

Logger.h

//
//  Logger.h
//
//  Created by MJ (Ruit) on 1/1/19.
//

#ifndef Logger_h
#define Logger_h

// #include <jni.h>
#include <android/log.h>

enum LogType {
    oDEBUG = 3,
    oERROR = 6,
    oINFO  = 4,
    oWARN  = 5
};

// TAG is a prefix in front of log to help you filter logs
#define TAG "PJ: "
#define LOGD(...) ((void)__android_log_print(oDEBUG, TAG, __VA_ARGS__))
#define LOGE(...) ((void)__android_log_print(oERROR, TAG, __VA_ARGS__))
#define LOGI(...) ((void)__android_log_print(oINFO,  TAG, __VA_ARGS__))
#define LOGW(...) ((void)__android_log_print(oWARN,  TAG, __VA_ARGS__))

#endif /* Logger_h */

main.cpp

 int n = 5;
 LOGI("n: %d", n);

reference:
https://android.googlesource.com/platform/system/core/+/refs/heads/eclair-sholes-release2/include/android/log.h

Activity

  1. sassan-dev commented on Aug 14, 2024

    @sassan-dev
    Owner

    Thank you for your question!
    I'm not an Android developer, but is it possible to use the library on Android with this customization?
    BTW, this feature is part of the next version (v0.7.0), which I plan to release in a few weeks.

  2. ascorbic-acid commented on Aug 14, 2024

    @ascorbic-acid
    Author

    yes that feature work, i did not know about it, thanks

    template <>
    void cpp_dump::write_log(std::string_view output) {
        LOGI("DUMP: %s", output);
    }
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions