2020-06-07 00:37:49 +03:00
|
|
|
#include "JniConvertors.hpp"
|
2020-06-18 20:54:59 +03:00
|
|
|
#include "LogManagerBase.hpp"
|
2020-06-22 21:44:54 +03:00
|
|
|
#include "WrapperLogManager.hpp"
|
2020-05-31 23:50:25 +03:00
|
|
|
|
|
|
|
using namespace MAT;
|
|
|
|
|
2020-06-18 20:54:59 +03:00
|
|
|
template <>
|
|
|
|
ILogManager* LogManagerBase<WrapperConfig>::instance{};
|
|
|
|
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
JNIEXPORT jlong JNICALL Java_com_microsoft_applications_events_LogManager_nativeInitializeWithoutTenantToken(
|
2020-05-31 23:50:25 +03:00
|
|
|
JNIEnv* /* env */,
|
2020-06-18 20:54:59 +03:00
|
|
|
jclass /* this */)
|
|
|
|
{
|
|
|
|
ILogger* logger = WrapperLogManager::Initialize();
|
|
|
|
return reinterpret_cast<jlong>(logger);
|
|
|
|
}
|
2020-05-31 23:50:25 +03:00
|
|
|
|
2020-06-18 20:54:59 +03:00
|
|
|
JNIEXPORT jlong JNICALL Java_com_microsoft_applications_events_LogManager_nativeInitializeWithTenantToken(
|
2020-05-31 23:50:25 +03:00
|
|
|
JNIEnv* env,
|
|
|
|
jclass /* this */,
|
2020-06-18 20:54:59 +03:00
|
|
|
jstring jTenantToken)
|
|
|
|
{
|
|
|
|
auto tenantToken = JStringToStdString(env, jTenantToken);
|
|
|
|
ILogger* logger = WrapperLogManager::Initialize(tenantToken);
|
|
|
|
return reinterpret_cast<jlong>(logger);
|
|
|
|
}
|
|
|
|
|
|
|
|
JNIEXPORT jint JNICALL Java_com_microsoft_applications_events_LogManager_nativeFlushAndTeardown(
|
2020-05-31 23:50:25 +03:00
|
|
|
JNIEnv* /* env */,
|
2020-06-18 20:54:59 +03:00
|
|
|
jclass /* this */)
|
|
|
|
{
|
|
|
|
return static_cast<jint>(WrapperLogManager::FlushAndTeardown());
|
|
|
|
}
|
2020-05-31 23:50:25 +03:00
|
|
|
|
2020-06-18 20:54:59 +03:00
|
|
|
JNIEXPORT jint JNICALL Java_com_microsoft_applications_events_LogManager_nativeFlush(
|
2020-05-31 23:50:25 +03:00
|
|
|
JNIEnv* /* env */,
|
2020-06-18 20:54:59 +03:00
|
|
|
jclass /* this */)
|
|
|
|
{
|
|
|
|
return static_cast<jint>(WrapperLogManager::Flush());
|
|
|
|
}
|
2020-05-31 23:50:25 +03:00
|
|
|
|
2020-06-18 20:54:59 +03:00
|
|
|
JNIEXPORT jint JNICALL Java_com_microsoft_applications_events_LogManager_nativeUploadNow(
|
2020-05-31 23:50:25 +03:00
|
|
|
JNIEnv* /* env */,
|
2020-06-18 20:54:59 +03:00
|
|
|
jclass /* this */)
|
|
|
|
{
|
|
|
|
return static_cast<jint>(WrapperLogManager::UploadNow());
|
|
|
|
}
|
2020-05-31 23:50:25 +03:00
|
|
|
|
2020-06-18 20:54:59 +03:00
|
|
|
JNIEXPORT jint JNICALL Java_com_microsoft_applications_events_LogManager_nativePauseTransmission(
|
2020-05-31 23:50:25 +03:00
|
|
|
JNIEnv* /* env */,
|
2020-06-18 20:54:59 +03:00
|
|
|
jclass /* this */)
|
|
|
|
{
|
|
|
|
return static_cast<jint>(WrapperLogManager::PauseTransmission());
|
|
|
|
}
|
2020-05-31 23:50:25 +03:00
|
|
|
|
2020-06-18 20:54:59 +03:00
|
|
|
JNIEXPORT jint JNICALL Java_com_microsoft_applications_events_LogManager_nativeResumeTransmission(
|
2020-05-31 23:50:25 +03:00
|
|
|
JNIEnv* /* env */,
|
2020-06-18 20:54:59 +03:00
|
|
|
jclass /* this */)
|
|
|
|
{
|
|
|
|
return static_cast<jint>(WrapperLogManager::ResumeTransmission());
|
|
|
|
}
|
2020-05-31 23:50:25 +03:00
|
|
|
|
2020-06-18 20:54:59 +03:00
|
|
|
JNIEXPORT jint JNICALL Java_com_microsoft_applications_events_LogManager_nativeSetIntTransmitProfile(
|
2020-05-31 23:50:25 +03:00
|
|
|
JNIEnv* /* env */,
|
|
|
|
jclass /* this */,
|
2020-06-18 20:54:59 +03:00
|
|
|
jint jProfile)
|
|
|
|
{
|
|
|
|
return static_cast<jint>(WrapperLogManager::SetTransmitProfile(
|
2020-05-31 23:50:25 +03:00
|
|
|
static_cast<TransmitProfile>(jProfile)));
|
2020-06-18 20:54:59 +03:00
|
|
|
}
|
2020-05-31 23:50:25 +03:00
|
|
|
|
2020-06-18 20:54:59 +03:00
|
|
|
JNIEXPORT jint JNICALL Java_com_microsoft_applications_events_LogManager_nativeSetTransmitProfileString(
|
2020-05-31 23:50:25 +03:00
|
|
|
JNIEnv* env,
|
|
|
|
jclass /* this */,
|
2020-06-18 20:54:59 +03:00
|
|
|
jstring jstrProfile)
|
|
|
|
{
|
|
|
|
return static_cast<jint>(WrapperLogManager::SetTransmitProfile(JStringToStdString(env, jstrProfile)));
|
|
|
|
}
|
2020-05-31 23:50:25 +03:00
|
|
|
|
2020-06-18 20:54:59 +03:00
|
|
|
JNIEXPORT jint JNICALL Java_com_microsoft_applications_events_LogManager_nativeLoadTransmitProfilesString(
|
2020-05-31 23:50:25 +03:00
|
|
|
JNIEnv* env,
|
|
|
|
jclass /* this */,
|
2020-06-18 20:54:59 +03:00
|
|
|
jstring jstrProfilesJson)
|
|
|
|
{
|
|
|
|
return static_cast<jint>(WrapperLogManager::LoadTransmitProfiles(JStringToStdString(env, jstrProfilesJson)));
|
|
|
|
}
|
2020-05-31 23:50:25 +03:00
|
|
|
|
2020-06-18 20:54:59 +03:00
|
|
|
JNIEXPORT jint JNICALL Java_com_microsoft_applications_events_LogManager_nativeResetTransmitProfiles(
|
2020-05-31 23:50:25 +03:00
|
|
|
JNIEnv* /* env */,
|
2020-06-18 20:54:59 +03:00
|
|
|
jclass /* this */)
|
|
|
|
{
|
|
|
|
return static_cast<jint>(WrapperLogManager::ResetTransmitProfiles());
|
|
|
|
}
|
2020-05-31 23:50:25 +03:00
|
|
|
|
2020-06-18 20:54:59 +03:00
|
|
|
JNIEXPORT jstring JNICALL Java_com_microsoft_applications_events_LogManager_getTransmitProfileName(
|
2020-05-31 23:50:25 +03:00
|
|
|
JNIEnv* env,
|
2020-06-18 20:54:59 +03:00
|
|
|
jclass /* this */)
|
|
|
|
{
|
|
|
|
std::string profileName = WrapperLogManager::GetTransmitProfileName();
|
|
|
|
return static_cast<jstring>(env->NewStringUTF(profileName.c_str()));
|
|
|
|
}
|
2020-05-31 23:50:25 +03:00
|
|
|
|
2020-06-18 20:54:59 +03:00
|
|
|
JNIEXPORT jlong JNICALL Java_com_microsoft_applications_events_LogManager_nativeGetSemanticContext(
|
2020-05-31 23:50:25 +03:00
|
|
|
JNIEnv* env,
|
2020-06-18 20:54:59 +03:00
|
|
|
jclass /* this */)
|
|
|
|
{
|
|
|
|
return reinterpret_cast<jlong>(WrapperLogManager::GetSemanticContext());
|
|
|
|
}
|
2020-05-31 23:50:25 +03:00
|
|
|
|
2020-06-18 20:54:59 +03:00
|
|
|
JNIEXPORT jlong JNICALL Java_com_microsoft_applications_events_LogManager_nativeSetContextStringValue(
|
2020-05-31 23:50:25 +03:00
|
|
|
JNIEnv* env,
|
|
|
|
jclass /* this */,
|
|
|
|
jstring jstrName,
|
|
|
|
jstring jstrValue,
|
2020-06-18 20:54:59 +03:00
|
|
|
jint piiKind)
|
|
|
|
{
|
|
|
|
auto name = JStringToStdString(env, jstrName);
|
|
|
|
auto value = JStringToStdString(env, jstrValue);
|
|
|
|
return static_cast<jint>(WrapperLogManager::SetContext(name, value, static_cast<PiiKind>(piiKind)));
|
|
|
|
}
|
|
|
|
|
|
|
|
JNIEXPORT jlong JNICALL Java_com_microsoft_applications_events_LogManager_nativeSetContextIntValue(
|
2020-05-31 23:50:25 +03:00
|
|
|
JNIEnv* env,
|
|
|
|
jclass /* this */,
|
|
|
|
jstring jstrName,
|
|
|
|
jint jValue,
|
2020-06-18 20:54:59 +03:00
|
|
|
jint piiKind)
|
|
|
|
{
|
|
|
|
auto name = JStringToStdString(env, jstrName);
|
|
|
|
return static_cast<jint>(WrapperLogManager::SetContext(name, static_cast<int32_t>(jValue), static_cast<PiiKind>(piiKind)));
|
|
|
|
}
|
2020-05-31 23:50:25 +03:00
|
|
|
|
2020-06-18 20:54:59 +03:00
|
|
|
JNIEXPORT jlong JNICALL Java_com_microsoft_applications_events_LogManager_nativeSetContextLongValue(
|
2020-05-31 23:50:25 +03:00
|
|
|
JNIEnv* env,
|
|
|
|
jclass /* this */,
|
|
|
|
jstring jstrName,
|
|
|
|
jlong jValue,
|
2020-06-18 20:54:59 +03:00
|
|
|
jint piiKind)
|
|
|
|
{
|
|
|
|
auto name = JStringToStdString(env, jstrName);
|
|
|
|
return static_cast<jint>(WrapperLogManager::SetContext(name, static_cast<int64_t>(jValue), static_cast<PiiKind>(piiKind)));
|
|
|
|
}
|
2020-05-31 23:50:25 +03:00
|
|
|
|
2020-06-18 20:54:59 +03:00
|
|
|
JNIEXPORT jlong JNICALL Java_com_microsoft_applications_events_LogManager_nativeSetContextDoubleValue(
|
2020-05-31 23:50:25 +03:00
|
|
|
JNIEnv* env,
|
|
|
|
jclass /* this */,
|
|
|
|
jstring jstrName,
|
|
|
|
jdouble jValue,
|
2020-06-18 20:54:59 +03:00
|
|
|
jint piiKind)
|
|
|
|
{
|
|
|
|
auto name = JStringToStdString(env, jstrName);
|
|
|
|
return static_cast<jint>(WrapperLogManager::SetContext(name, static_cast<double>(jValue), static_cast<PiiKind>(piiKind)));
|
|
|
|
}
|
2020-05-31 23:50:25 +03:00
|
|
|
|
2020-06-18 20:54:59 +03:00
|
|
|
JNIEXPORT jlong JNICALL Java_com_microsoft_applications_events_LogManager_nativeSetContextBoolValue(
|
2020-05-31 23:50:25 +03:00
|
|
|
JNIEnv* env,
|
|
|
|
jclass /* this */,
|
|
|
|
jstring jstrName,
|
|
|
|
jboolean jValue,
|
2020-06-18 20:54:59 +03:00
|
|
|
jint piiKind)
|
|
|
|
{
|
|
|
|
auto name = JStringToStdString(env, jstrName);
|
|
|
|
return static_cast<jint>(WrapperLogManager::SetContext(name, static_cast<bool>(jValue), static_cast<PiiKind>(piiKind)));
|
|
|
|
}
|
2020-05-31 23:50:25 +03:00
|
|
|
|
2020-06-18 20:54:59 +03:00
|
|
|
JNIEXPORT jlong JNICALL Java_com_microsoft_applications_events_LogManager_nativeSetContextTimeTicksValue(
|
2020-05-31 23:50:25 +03:00
|
|
|
JNIEnv* env,
|
|
|
|
jclass /* this */,
|
|
|
|
jstring jstrName,
|
|
|
|
jlong jValue,
|
2020-06-18 20:54:59 +03:00
|
|
|
jint piiKind)
|
|
|
|
{
|
|
|
|
auto name = JStringToStdString(env, jstrName);
|
|
|
|
return static_cast<jint>(WrapperLogManager::SetContext(name, time_ticks_t(static_cast<uint64_t>(jValue)), static_cast<PiiKind>(piiKind)));
|
|
|
|
}
|
2020-05-31 23:50:25 +03:00
|
|
|
|
2020-06-18 20:54:59 +03:00
|
|
|
JNIEXPORT jlong JNICALL Java_com_microsoft_applications_events_LogManager_nativeSetContextGuidValue(
|
2020-05-31 23:50:25 +03:00
|
|
|
JNIEnv* env,
|
|
|
|
jclass /* this */,
|
|
|
|
jstring jstrName,
|
|
|
|
jstring jstrValue,
|
2020-06-18 20:54:59 +03:00
|
|
|
jint piiKind)
|
|
|
|
{
|
|
|
|
auto name = JStringToStdString(env, jstrName);
|
|
|
|
auto value = JStringToStdString(env, jstrValue);
|
|
|
|
return static_cast<jint>(WrapperLogManager::SetContext(name, GUID_t(value.c_str()), static_cast<PiiKind>(piiKind)));
|
|
|
|
}
|
|
|
|
|
|
|
|
JNIEXPORT jlong JNICALL Java_com_microsoft_applications_events_LogManager_nativeGetLogger(
|
2020-05-31 23:50:25 +03:00
|
|
|
JNIEnv* /* env */,
|
2020-06-18 20:54:59 +03:00
|
|
|
jclass /* this */)
|
|
|
|
{
|
|
|
|
ILogger* logger = WrapperLogManager::GetLogger();
|
|
|
|
return reinterpret_cast<jlong>(logger);
|
|
|
|
}
|
2020-05-31 23:50:25 +03:00
|
|
|
|
2020-06-18 20:54:59 +03:00
|
|
|
JNIEXPORT jlong JNICALL Java_com_microsoft_applications_events_LogManager_nativeGetLoggerWithSource(
|
2020-05-31 23:50:25 +03:00
|
|
|
JNIEnv* env,
|
|
|
|
jclass /* this */,
|
2020-06-18 20:54:59 +03:00
|
|
|
jstring jstrSource)
|
|
|
|
{
|
|
|
|
auto source = JStringToStdString(env, jstrSource);
|
|
|
|
ILogger* logger = WrapperLogManager::GetLogger(source);
|
|
|
|
return reinterpret_cast<jlong>(logger);
|
|
|
|
}
|
|
|
|
|
|
|
|
JNIEXPORT jlong JNICALL Java_com_microsoft_applications_events_LogManager_nativeGetLoggerWithTenantTokenAndSource(
|
2020-05-31 23:50:25 +03:00
|
|
|
JNIEnv* env,
|
|
|
|
jclass /* this */,
|
|
|
|
jstring jstrTenantToken,
|
2020-06-18 20:54:59 +03:00
|
|
|
jstring jstrSource)
|
|
|
|
{
|
|
|
|
auto tenantToken = JStringToStdString(env, jstrTenantToken);
|
|
|
|
auto source = JStringToStdString(env, jstrSource);
|
|
|
|
ILogger* logger = WrapperLogManager::GetLogger(tenantToken, source);
|
|
|
|
return reinterpret_cast<jlong>(logger);
|
|
|
|
}
|
2020-05-31 23:50:25 +03:00
|
|
|
}
|