android: add logging
parent
9848610ea2
commit
f767b5fdef
@ -0,0 +1,15 @@
|
||||
#include "common/logging/log.h"
|
||||
#include "native_interface.h"
|
||||
|
||||
namespace Log {
|
||||
extern "C" {
|
||||
JNICALL void Java_org_citra_1emu_citra_LOG_logEntry(JNIEnv* env, jclass type, jint level,
|
||||
jstring file_name, jint line_number,
|
||||
jstring function, jstring msg) {
|
||||
using CitraJNI::GetJString;
|
||||
FmtLogMessage(Class::Frontend, static_cast<Level>(level), GetJString(env, file_name).data(),
|
||||
static_cast<unsigned int>(line_number), GetJString(env, function).data(),
|
||||
GetJString(env, msg).data());
|
||||
}
|
||||
}
|
||||
} // namespace Log
|
@ -0,0 +1,38 @@
|
||||
// Copyright 2019 Citra Emulator Project
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <android/log.h>
|
||||
#include "common/assert.h"
|
||||
#include "common/logging/text_formatter.h"
|
||||
#include "logcat_backend.h"
|
||||
|
||||
namespace Log {
|
||||
void LogcatBackend::Write(const Entry& entry) {
|
||||
android_LogPriority priority;
|
||||
switch (entry.log_level) {
|
||||
case Level::Trace:
|
||||
priority = ANDROID_LOG_VERBOSE;
|
||||
break;
|
||||
case Level::Debug:
|
||||
priority = ANDROID_LOG_DEBUG;
|
||||
break;
|
||||
case Level::Info:
|
||||
priority = ANDROID_LOG_INFO;
|
||||
break;
|
||||
case Level::Warning:
|
||||
priority = ANDROID_LOG_WARN;
|
||||
break;
|
||||
case Level::Error:
|
||||
priority = ANDROID_LOG_ERROR;
|
||||
break;
|
||||
case Level::Critical:
|
||||
priority = ANDROID_LOG_FATAL;
|
||||
break;
|
||||
case Level::Count:
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
__android_log_print(priority, "citra", "%s\n", FormatLogMessage(entry).c_str());
|
||||
}
|
||||
} // namespace Log
|
@ -0,0 +1,22 @@
|
||||
// Copyright 2019 Citra Emulator Project
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "common/logging/backend.h"
|
||||
|
||||
namespace Log {
|
||||
class LogcatBackend : public Backend {
|
||||
public:
|
||||
static const char* Name() {
|
||||
return "Logcat";
|
||||
}
|
||||
|
||||
const char* GetName() const override {
|
||||
return Name();
|
||||
}
|
||||
|
||||
void Write(const Entry& entry) override;
|
||||
};
|
||||
} // namespace Log
|
@ -0,0 +1,41 @@
|
||||
package org.citra_emu.citra;
|
||||
|
||||
public class LOG {
|
||||
|
||||
private interface LOG_LEVEL {
|
||||
int TRACE = 0, DEBUG = 1, INFO = 2, WARNING = 3, ERROR = 4, CRITICAL = 5;
|
||||
}
|
||||
|
||||
public static void TRACE(String msg, Object... args) {
|
||||
LOG(LOG_LEVEL.TRACE, msg, args);
|
||||
}
|
||||
|
||||
public static void DEBUG(String msg, Object... args) {
|
||||
LOG(LOG_LEVEL.DEBUG, msg, args);
|
||||
}
|
||||
|
||||
public static void INFO(String msg, Object... args) {
|
||||
LOG(LOG_LEVEL.INFO, msg, args);
|
||||
}
|
||||
|
||||
public static void WARNING(String msg, Object... args) {
|
||||
LOG(LOG_LEVEL.WARNING, msg, args);
|
||||
}
|
||||
|
||||
public static void ERROR(String msg, Object... args) {
|
||||
LOG(LOG_LEVEL.ERROR, msg, args);
|
||||
}
|
||||
|
||||
public static void CRITICAL(String msg, Object... args) {
|
||||
LOG(LOG_LEVEL.CRITICAL, msg, args);
|
||||
}
|
||||
|
||||
private static void LOG(int level, String msg, Object... args) {
|
||||
StackTraceElement trace = Thread.currentThread().getStackTrace()[4];
|
||||
logEntry(level, trace.getFileName(), trace.getLineNumber(), trace.getMethodName(),
|
||||
String.format(msg, args));
|
||||
}
|
||||
|
||||
private static native void logEntry(int level, String file_name, int line_number,
|
||||
String function, String message);
|
||||
}
|
Loading…
Reference in New Issue