Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

真机调试和printLog #28

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,17 @@ public class DebugConnection extends Socket {

private static final String EMULATOR_LOCALHOST = "10.0.2.2";
private static final String GENYMOTION_LOCALHOST = "10.0.3.2";
private static final String DEVICE_LOCALHOST = "localhost";
private static String DEVICE_LOCALHOST = "localhost";
private static final int PORT = 9876;

private DataInputStream input = null;
private DataOutputStream output = null;

public boolean sendingEnabled = true;

public static void setDeviceLocalhost(String deviceLocalhost) {
DEVICE_LOCALHOST = deviceLocalhost;
}

private static String getDebugServerHost() {
// Since genymotion runs in vbox it use different hostname to refer to adb host.
Expand Down
19 changes: 19 additions & 0 deletions Android/LuaViewSDK/src/com/taobao/luaview/vm/extend/BaseLib.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public BaseLib(org.luaj.vm2.lib.BaseLib baseLib, Globals globals) {

public void extend(LuaValue env) {
env.set("printLV", new printLV(baseLib));
env.set("printLog", new printLog(baseLib));
}

// "print", // (...) -> void
Expand Down Expand Up @@ -56,4 +57,22 @@ public Varargs invoke(Varargs args) {
return NONE;
}
}

// "printLog(fileName, messsage)", send log info to LuaViewDebugger
final class printLog extends TwoArgFunction {
final org.luaj.vm2.lib.BaseLib baseLib;

public log(org.luaj.vm2.lib.BaseLib baseLib) {
this.baseLib = baseLib;
}

@Override public LuaValue call(LuaValue arg1, LuaValue arg2) {
String fileName = arg1.checkjstring();
if (globals.debugConnection != null) {
globals.debugConnection.sendCmd("log", fileName, arg2.checkjstring());
}
LogUtil.i(arg2);
return NONE;
}
}
}