Skip to content

Commit a54e34c

Browse files
authored
Update libxposed and implement new Log API (#582)
- Implement the new `XposedInterface.log(int, String, String, Throwable)` in `LSPosedContext`. - Refactor existing log methods to route through the centralized implementation. - Enhance `Utils.Log` utility: - Add standard Android log priority constants. - Implement `println` with support for the `muted` flag. - Update default `LOG_TAG` to "Vector".
1 parent 8db1921 commit a54e34c

3 files changed

Lines changed: 34 additions & 4 deletions

File tree

core/src/main/java/org/lsposed/lspd/impl/LSPosedContext.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,12 +311,29 @@ public <T, U> U newInstanceSpecial(@NonNull Constructor<T> constructor, @NonNull
311311

312312
@Override
313313
public void log(@NonNull String message) {
314-
Log.i(TAG, mPackageName + ": " + message);
314+
log(Log.INFO, null, message, null);
315315
}
316316

317317
@Override
318318
public void log(@NonNull String message, @NonNull Throwable throwable) {
319-
Log.e(TAG, mPackageName + ": " + message, throwable);
319+
log(Log.ERROR, null, message, throwable);
320+
}
321+
322+
@Override
323+
public void log(int priority, @Nullable String tag, @NonNull String msg, @Nullable Throwable tr) {
324+
String finalTag = (tag != null) ? tag : TAG;
325+
326+
// Format the message with the package name prefix
327+
String prefix = (mPackageName != null) ? mPackageName + ": " : "";
328+
StringBuilder fullMsg = new StringBuilder(prefix).append(msg);
329+
330+
// Handle the Throwable if present
331+
if (tr != null) {
332+
fullMsg.append("\n").append(Log.getStackTraceString(tr));
333+
}
334+
335+
// Use the low-level println to handle dynamic priorities
336+
Log.println(priority, finalTag, fullMsg.toString());
320337
}
321338

322339
@Override

services/daemon-service/src/main/java/org/lsposed/lspd/util/Utils.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,26 @@
2929

3030
public class Utils {
3131

32-
public static final String LOG_TAG = "LSPosed";
32+
public static final String LOG_TAG = "Vector";
3333
public static final boolean isMIUI = !TextUtils.isEmpty(SystemProperties.get("ro.miui.ui.version.name"));
3434
public static final boolean isLENOVO = !TextUtils.isEmpty(SystemProperties.get("ro.lenovo.region"));
3535

3636
public class Log {
37+
public static final int VERBOSE = android.util.Log.VERBOSE;
38+
public static final int DEBUG = android.util.Log.DEBUG;
39+
public static final int INFO = android.util.Log.INFO;
40+
public static final int WARN = android.util.Log.WARN;
41+
public static final int ERROR = android.util.Log.ERROR;
42+
public static final int ASSERT = android.util.Log.ASSERT;
43+
3744
public static boolean muted = false;
3845

46+
public static void println(int priority, String tag, String msg) {
47+
// Respect the muted flag for everything except ERROR/ASSERT
48+
if (muted && priority < android.util.Log.ERROR) return;
49+
android.util.Log.println(priority, tag, msg);
50+
}
51+
3952
public static String getStackTraceString(Throwable tr) {
4053
return android.util.Log.getStackTraceString(tr);
4154
}

0 commit comments

Comments
 (0)