mirror of
https://github.com/servo/servo.git
synced 2025-07-02 04:53:39 +01:00
Enable use of RUST_LOG with mach run --android.
This commit is contained in:
parent
a6dbfdd29f
commit
f7516f57a7
7 changed files with 31 additions and 15 deletions
|
@ -12,6 +12,7 @@ use jni::objects::{GlobalRef, JClass, JObject, JString, JValue};
|
|||
use jni::sys::{jboolean, jfloat, jint, jstring, JNI_TRUE};
|
||||
use log::Level;
|
||||
use std;
|
||||
use std::borrow::Cow;
|
||||
use std::os::raw::c_void;
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
|
@ -49,6 +50,7 @@ pub fn Java_com_mozilla_servoview_JNIServo_init(
|
|||
activity: JObject,
|
||||
args: JString,
|
||||
url: JString,
|
||||
log_str: JString,
|
||||
callbacks_obj: JObject,
|
||||
width: jint,
|
||||
height: jint,
|
||||
|
@ -58,14 +60,17 @@ pub fn Java_com_mozilla_servoview_JNIServo_init(
|
|||
// Note: Android debug logs are stripped from a release build.
|
||||
// debug!() will only show in a debug build. Use info!() if logs
|
||||
// should show up in adb logcat with a release build.
|
||||
android_logger::init_once(
|
||||
Filter::default()
|
||||
let mut filter = Filter::default()
|
||||
.with_min_level(Level::Debug)
|
||||
.with_allowed_module_path("simpleservo::api")
|
||||
.with_allowed_module_path("simpleservo::jniapi")
|
||||
.with_allowed_module_path("simpleservo::gl_glue::egl"),
|
||||
Some("simpleservo")
|
||||
);
|
||||
.with_allowed_module_path("simpleservo::gl_glue::egl");
|
||||
let log_str = env.get_string(log_str).ok();
|
||||
let log_str = log_str.as_ref().map_or(Cow::Borrowed(""), |s| s.to_string_lossy());
|
||||
for module in log_str.split(',') {
|
||||
filter = filter.with_allowed_module_path(module);
|
||||
}
|
||||
android_logger::init_once(filter, Some("simpleservo"));
|
||||
}
|
||||
|
||||
info!("init");
|
||||
|
|
|
@ -99,6 +99,9 @@ class PostBuildCommands(CommandBase):
|
|||
]
|
||||
json_params = shell_quote(json.dumps(params))
|
||||
extra = "-e servoargs " + json_params
|
||||
rust_log = env.get("RUST_LOG", None)
|
||||
if rust_log:
|
||||
extra += " -e servolog " + rust_log
|
||||
script += [
|
||||
"am start " + extra + " com.mozilla.servo/com.mozilla.servo.MainActivity",
|
||||
"sleep 0.5",
|
||||
|
|
|
@ -71,7 +71,8 @@ public class MainActivity extends Activity implements Servo.Client {
|
|||
}
|
||||
|
||||
String args = getIntent().getStringExtra("servoargs");
|
||||
mServoView.setServoArgs(args);
|
||||
String log = getIntent().getStringExtra("servolog");
|
||||
mServoView.setServoArgs(args, log);
|
||||
|
||||
setupUrlField();
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ public class JNIServo {
|
|||
public native void init(Activity activity,
|
||||
String args,
|
||||
String url,
|
||||
String logstr,
|
||||
Callbacks callbacks,
|
||||
int width, int height, boolean log);
|
||||
|
||||
|
|
|
@ -24,7 +24,9 @@ public class Servo {
|
|||
GfxCallbacks gfxcb,
|
||||
Client client,
|
||||
Activity activity,
|
||||
String args, String url,
|
||||
String args,
|
||||
String url,
|
||||
String logstr,
|
||||
int width, int height, boolean log) {
|
||||
|
||||
mRunCallback = runCallback;
|
||||
|
@ -34,7 +36,7 @@ public class Servo {
|
|||
Callbacks cbs = new Callbacks(client, gfxcb);
|
||||
|
||||
mRunCallback.inGLThread(() -> {
|
||||
mJNI.init(activity, args, url, cbs, width, height, log);
|
||||
mJNI.init(activity, args, url, logstr, cbs, width, height, log);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ public class ServoSurface {
|
|||
private Servo mServo;
|
||||
private Client mClient = null;
|
||||
private String mServoArgs = "";
|
||||
private String mServoLog = "";
|
||||
private String mInitialUri = null;
|
||||
private Activity mActivity;
|
||||
|
||||
|
@ -53,8 +54,9 @@ public class ServoSurface {
|
|||
mClient = client;
|
||||
}
|
||||
|
||||
public void setServoArgs(String args) {
|
||||
public void setServoArgs(String args, String log) {
|
||||
mServoArgs = args != null ? args : "";
|
||||
mServoLog = log != null ? log : "";
|
||||
}
|
||||
|
||||
public void setActivity(Activity activity) {
|
||||
|
@ -204,7 +206,7 @@ public class ServoSurface {
|
|||
inUIThread(() -> {
|
||||
final boolean showLogs = true;
|
||||
String uri = mInitialUri == null ? null : mInitialUri;
|
||||
mServo = new Servo(this, surface, mClient, mActivity, mServoArgs, uri, mWidth, mHeight, showLogs);
|
||||
mServo = new Servo(this, surface, mClient, mActivity, mServoArgs, uri, mServoLog, mWidth, mHeight, showLogs);
|
||||
});
|
||||
|
||||
Looper.loop();
|
||||
|
|
|
@ -41,6 +41,7 @@ public class ServoView extends GLSurfaceView
|
|||
private Uri mInitialUri = null;
|
||||
private boolean mAnimating;
|
||||
private String mServoArgs = "";
|
||||
private String mServoLog = "";
|
||||
private GestureDetector mGestureDetector;
|
||||
private ScaleGestureDetector mScaleGestureDetector;
|
||||
|
||||
|
@ -72,8 +73,9 @@ public class ServoView extends GLSurfaceView
|
|||
initGestures(context);
|
||||
}
|
||||
|
||||
public void setServoArgs(String args) {
|
||||
public void setServoArgs(String args, String log) {
|
||||
mServoArgs = args != null ? args : "";
|
||||
mServoLog = log != null ? log : "";
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
|
@ -139,7 +141,7 @@ public class ServoView extends GLSurfaceView
|
|||
int height = getHeight();
|
||||
inGLThread(() -> {
|
||||
String uri = mInitialUri == null ? null : mInitialUri.toString();
|
||||
mServo = new Servo(this, this, mClient, mActivity, mServoArgs, uri, width, height, showLogs);
|
||||
mServo = new Servo(this, this, mClient, mActivity, mServoArgs, uri, mServoLog, width, height, showLogs);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue