/*
 * HA_log.h
 *
 */

#ifndef HA_LOG_H_
#define HA_LOG_H_

#include "HA_config.h"

#ifndef IS_APPLE_IOS

#ifdef ENABLE_JNI_FOR_ANDROID
#include <jni.h>
#endif // ENABLE_JNI_FOR_ANDROID
#ifdef ENABLE_ANDROID_FUNCTION
#include <android/log.h>
//#define EXPORT __attribute__((visibility("default")))
#define LOG_TAG "embeddedhark"
#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__))
#define LOGD(...) ((void)__android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__))
#define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__))
#else // ENABLE_ANDROID_FUNCTION
#define LOGI(...) (printf(__VA_ARGS__), printf("\n"), fflush(stdout))
#define LOGD(...) (printf(__VA_ARGS__), printf("\n"), fflush(stdout))
#define LOGE(...) (printf(__VA_ARGS__), printf("\n"), fflush(stdout))
//#define LOGI(...)
//#define LOGD(...)
//#define LOGE(...)
#endif // ENABLE_ANDROID_FUNCTION

#else // IS_APPLE_IOS

#include <stdio.h>
#include <string.h>

//#define LOGI(...) (printf(__VA_ARGS__))
//#define LOGD(...) (printf(__VA_ARGS__))
//#define LOGE(...) (printf(__VA_ARGS__))

#ifdef __cplusplus
extern "C" {
#endif
extern void logmsg(const char * const s, ...);
#ifdef __cplusplus
}
#endif

#define LOGI(...) (logmsg(__VA_ARGS__))
#define LOGD(...) (logmsg(__VA_ARGS__))
#define LOGE(...) (logmsg(__VA_ARGS__))

#endif // IS_APPLE_IOS

#define NELEM(array) (sizeof(array) / sizeof(array[0]))

#endif /* HA_LOG_H_ */
