Merge branch 'master' into maharrim/specialjni

This commit is contained in:
larvacea 2020-06-24 08:52:00 -07:00
Родитель 8a96da8979 728a3fefc0
Коммит 18380ba784
4 изменённых файлов: 45 добавлений и 43 удалений

2
.gitignore поставляемый
Просмотреть файл

@ -399,4 +399,6 @@ zlib/contrib/vstudio/vc14/x64/
# Xcode generated files
*.xcworkspacedata
*.xcuserstate
# Visual Code
*.code-workspace

Просмотреть файл

@ -520,6 +520,4 @@ public class LogManager {
* @return boolean value for success or failure
*/
public native static boolean isViewerEnabled();
public native static String getCurrentEndpoint();
}

Просмотреть файл

@ -9,59 +9,35 @@ using namespace MAT;
extern "C"
{
std::shared_ptr<DefaultDataViewer> spDefaultDataViewer;
JNIEXPORT jboolean JNICALL Java_com_microsoft_applications_events_LogManager_initializeDiagnosticDataViewer(
JNIEnv* env,
jclass /* this */,
jstring jstrMachineIdentifier,
jstring jstrEndpoint)
{
auto machineIdentifier = JStringToStdString(env, jstrMachineIdentifier);
auto endpoint = JStringToStdString(env, jstrEndpoint);
spDefaultDataViewer = std::make_shared<DefaultDataViewer>(nullptr, machineIdentifier);
if (spDefaultDataViewer->EnableRemoteViewer(endpoint))
{
WrapperLogManager::GetDataViewerCollection().UnregisterAllViewers();
WrapperLogManager::GetDataViewerCollection().RegisterViewer(std::static_pointer_cast<IDataViewer>(spDefaultDataViewer));
return true;
}
else
{
return false;
}
jstring jstrEndpoint) {
auto machineIdentifier = JStringToStdString(env, jstrMachineIdentifier);
auto endpoint = JStringToStdString(env, jstrEndpoint);
std::shared_ptr<DefaultDataViewer> spDefaultDataViewer = std::make_shared<DefaultDataViewer>(nullptr, machineIdentifier);
if (spDefaultDataViewer->EnableRemoteViewer(endpoint)) {
LogManager::GetDataViewerCollection().UnregisterAllViewers();
LogManager::GetDataViewerCollection().RegisterViewer(std::static_pointer_cast<IDataViewer>(spDefaultDataViewer));
return true;
}
else {
return false;
}
JNIEXPORT void JNICALL Java_com_microsoft_applications_events_LogManager_disableViewer(
JNIEnv* env,
jclass /* this */)
{
if (spDefaultDataViewer != nullptr)
{
spDefaultDataViewer->DisableViewer();
}
}
jclass /* this */) {
LogManager::GetDataViewerCollection().UnregisterAllViewers();
}
JNIEXPORT jboolean JNICALL Java_com_microsoft_applications_events_LogManager_isViewerEnabled(
JNIEnv* env,
jclass /* this */)
{
if (spDefaultDataViewer != nullptr)
{
return WrapperLogManager::GetDataViewerCollection().IsViewerEnabled(spDefaultDataViewer->GetName());
}
return false;
}
JNIEXPORT jString JNICALL Java_com_microsoft_applications_events_LogManager_getCurrentEndpoint(
JNIEnv* env,
jclass /* this */)
{
if (spDefaultDataViewer != nullptr)
{
return spDefaultDataViewer->GetCurrentEndpoint();
}
jclass /* this */) {
return LogManager::GetDataViewerCollection().IsViewerEnabled();
}
return "";
}

Просмотреть файл

@ -41,6 +41,10 @@
#include <oacr.h>
#endif
#ifdef ANDROID
#include <android/log.h>
#endif
#include <ctime>
namespace PAL_NS_BEGIN {
@ -164,6 +168,28 @@ namespace PAL_NS_BEGIN {
#endif
void log(LogLevel level, char const* component, char const* fmt, ...)
{
#if defined(ANDROID) && !defined(ANDROID_SUPPRESS_LOGCAT)
{
static android_LogPriority androidPriorities[] = {
ANDROID_LOG_UNKNOWN,
ANDROID_LOG_ERROR,
ANDROID_LOG_WARN,
ANDROID_LOG_INFO,
ANDROID_LOG_DEBUG
};
android_LogPriority prio = ANDROID_LOG_ERROR;
if (level > 0 && level < 5) {
prio = androidPriorities[level];
}
va_list ap;
va_start(ap, fmt);
__android_log_vprint(prio,
component,
fmt,
ap);
va_end(ap);
}
#endif
#ifdef HAVE_MAT_LOGGING
if (!isLoggingInited)
return;