Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
746cc63e63 |
No files matched your search
@@ -55,7 +55,7 @@ public class JavaGUILauncherActivity extends BaseActivity implements View.OnTouc
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_java_gui_launcher);
|
setContentView(R.layout.activity_java_gui_launcher);
|
||||||
|
|
||||||
Logger.begin(new File(Tools.DIR_GAME_HOME, "latestlog.txt").getAbsolutePath());
|
Logger.beginLog(new File(Tools.DIR_GAME_HOME, "latestlog.txt"));
|
||||||
mTouchCharInput = findViewById(R.id.awt_touch_char);
|
mTouchCharInput = findViewById(R.id.awt_touch_char);
|
||||||
mTouchCharInput.setCharacterSender(new AwtCharSender());
|
mTouchCharInput.setCharacterSender(new AwtCharSender());
|
||||||
|
|
||||||
|
|||||||
@@ -2,23 +2,47 @@ package net.kdt.pojavlaunch;
|
|||||||
|
|
||||||
import androidx.annotation.Keep;
|
import androidx.annotation.Keep;
|
||||||
|
|
||||||
/** Singleton class made to log on one file
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Singleton class made to log on one file
|
||||||
* The singleton part can be removed but will require more implementation from the end-dev
|
* The singleton part can be removed but will require more implementation from the end-dev
|
||||||
*/
|
*/
|
||||||
@Keep
|
@Keep
|
||||||
public class Logger {
|
public class Logger {
|
||||||
/** Print the text to the log file if not censored */
|
/**
|
||||||
|
* Print the text to the log file if not censored
|
||||||
|
*/
|
||||||
public static native void appendToLog(String text);
|
public static native void appendToLog(String text);
|
||||||
|
|
||||||
|
public static void beginLog(File logFile) {
|
||||||
|
try {
|
||||||
|
if (logFile.exists())
|
||||||
|
logFile.delete();
|
||||||
|
|
||||||
/** Reset the log file, effectively erasing any previous logs */
|
logFile.createNewFile();
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
Logger.begin(logFile.getAbsolutePath());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset the log file, effectively erasing any previous logs
|
||||||
|
*/
|
||||||
public static native void begin(String logFilePath);
|
public static native void begin(String logFilePath);
|
||||||
|
|
||||||
/** Small listener for anything listening to the log */
|
/**
|
||||||
|
* Link a log listener to the logger
|
||||||
|
*/
|
||||||
|
public static native void setLogListener(eventLogListener logListener);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Small listener for anything listening to the log
|
||||||
|
*/
|
||||||
public interface eventLogListener {
|
public interface eventLogListener {
|
||||||
void onEventLogged(String text);
|
void onEventLogged(String text);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Link a log listener to the logger */
|
|
||||||
public static native void setLogListener(eventLogListener logListener);
|
|
||||||
}
|
}
|
||||||
@@ -133,7 +133,7 @@ public class MainActivity extends BaseActivity implements ControlButtonMenuListe
|
|||||||
drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
|
drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Logger.begin(new File(Tools.DIR_GAME_HOME, "latestlog.txt").getAbsolutePath());
|
Logger.beginLog(new File(Tools.DIR_GAME_HOME, "latestlog.txt"));
|
||||||
// FIXME: is it safe for multi thread?
|
// FIXME: is it safe for multi thread?
|
||||||
GLOBAL_CLIPBOARD = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
|
GLOBAL_CLIPBOARD = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
|
||||||
touchCharInput.setCharacterSender(new LwjglCharSender());
|
touchCharInput.setCharacterSender(new LwjglCharSender());
|
||||||
|
|||||||
@@ -84,9 +84,9 @@ Java_net_kdt_pojavlaunch_Logger_begin(JNIEnv *env, __attribute((unused)) jclass
|
|||||||
dup2(pfd[1], 2);
|
dup2(pfd[1], 2);
|
||||||
|
|
||||||
/* open latestlog.txt for writing */
|
/* open latestlog.txt for writing */
|
||||||
const char* logFilePath = (*env)->GetStringUTFChars(env, logPath, NULL);
|
const char *logFilePath = (*env)->GetStringUTFChars(env, logPath, NULL);
|
||||||
latestlog_fd = open(logFilePath, O_WRONLY | O_TRUNC | O_CREAT, 644);
|
latestlog_fd = open(logFilePath, O_WRONLY | O_APPEND, 644);
|
||||||
if(latestlog_fd == -1) {
|
if (latestlog_fd == -1) {
|
||||||
latestlog_fd = 0;
|
latestlog_fd = 0;
|
||||||
(*env)->ThrowNew(env, ioeClass, strerror(errno));
|
(*env)->ThrowNew(env, ioeClass, strerror(errno));
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in new issue
Block a user