// // Created by #Suyghur, on 2021/06/21. // #include "include/logger.h" bool Logger::is_debug = true; void Logger::D(JNIEnv *env, const std::string &msg) { if (is_debug) { jclass clz = env->FindClass("cn/yyxx/columbus/base/utils/Logger"); if (clz == nullptr) { LOGE("Logger clz is null"); return; } const char *method_name = "d"; const char *sig = "(Ljava/lang/String;Ljava/lang/Object;)V"; jmethodID mid = env->GetStaticMethodID(clz, method_name, sig); jstring jtag = env->NewStringUTF(TAG); jstring jmsg = env->NewStringUTF(msg.c_str()); env->CallStaticVoidMethod(clz, mid, jtag, jmsg); } } void Logger::I(JNIEnv *env, const std::string &msg) { jclass clz = env->FindClass("cn/yyxx/columbus/base/utils/Logger"); if (clz == nullptr) { LOGE("Logger clz is null"); return; } const char *method_name = "i"; const char *sig = "(Ljava/lang/String;Ljava/lang/Object;)V"; jmethodID mid = env->GetStaticMethodID(clz, method_name, sig); jstring jtag = env->NewStringUTF(TAG); jstring jmsg = env->NewStringUTF(msg.c_str()); env->CallStaticVoidMethod(clz, mid, jtag, jmsg); } void Logger::E(JNIEnv *env, const std::string &msg) { jclass clz = env->FindClass("cn/yyxx/columbus/base/utils/Logger"); if (clz == nullptr) { LOGE("Logger clz is null"); return; } const char *method_name = "e"; const char *sig = "(Ljava/lang/String;Ljava/lang/Object;)V"; jmethodID mid = env->GetStaticMethodID(clz, method_name, sig); jstring jtag = env->NewStringUTF(TAG); jstring jmsg = env->NewStringUTF(msg.c_str()); env->CallStaticVoidMethod(clz, mid, jtag, jmsg); } void Logger::LogHandler(JNIEnv *env, const std::string &msg) { jclass clz = env->FindClass("cn/yyxx/columbus/base/utils/Logger"); if (clz == nullptr) { LOGE("Logger clz is null"); return; } const char *method_name = "logHandler"; const char *sig = "(Ljava/lang/String;)V"; jmethodID mid = env->GetStaticMethodID(clz, method_name, sig); jstring jmsg = env->NewStringUTF(msg.c_str()); env->CallStaticVoidMethod(clz, mid, jmsg); }