Loading core/proto/android/server/protolog.proto +1 −1 Original line number Diff line number Diff line Loading @@ -23,7 +23,7 @@ option java_multiple_files = true; /* represents a single log entry */ message ProtoLogMessage { /* log statement identifier, created from message string and log level. */ optional fixed32 message_hash = 1; optional sfixed32 message_hash = 1; /* log time, relative to the elapsed system time clock. */ optional fixed64 elapsed_realtime_nanos = 2; /* string parameters passed to the log call. */ Loading data/etc/services.core.protolog.json +3 −2 Original line number Diff line number Diff line { "version": "1.0.0", "messages": { "485522692": { "594230385": { "message": "Test completed successfully: %b %d %o %x %e %g %f %% %s.", "level": "ERROR", "group": "TEST_GROUP" "group": "TEST_GROUP", "at": "com\/android\/server\/wm\/ProtoLogGroup.java:94" } }, "groups": { Loading services/core/java/com/android/server/protolog/ProtoLogImpl.java +47 −39 Original line number Diff line number Diff line Loading @@ -110,6 +110,12 @@ public class ProtoLogImpl { getSingleInstance().log(LogLevel.WTF, group, messageHash, paramsMask, messageString, args); } /** Returns true iff logging is enabled for the given {@code IProtoLogGroup}. */ public static boolean isEnabled(IProtoLogGroup group) { return group.isLogToProto() || (group.isLogToProto() && getSingleInstance().isProtoEnabled()); } private static final int BUFFER_CAPACITY = 1024 * 1024; private static final String LOG_FILENAME = "/data/misc/wmtrace/wm_log.pb"; private static final String VIEWER_CONFIG_FILENAME = "/system/etc/protolog.conf.json.gz"; Loading Loading @@ -222,6 +228,7 @@ public class ProtoLogImpl { os.write(MESSAGE_HASH, messageHash); os.write(ELAPSED_REALTIME_NANOS, SystemClock.elapsedRealtimeNanos()); if (args != null) { int argIndex = 0; ArrayList<Long> longParams = new ArrayList<>(); ArrayList<Double> doubleParams = new ArrayList<>(); Loading Loading @@ -265,6 +272,7 @@ public class ProtoLogImpl { } os.writePackedBool(BOOLEAN_PARAMS, arr); } } os.end(token); mBuffer.add(os); } catch (Exception e) { Loading services/tests/servicestests/src/com/android/server/protolog/ProtoLogImplTest.java +2 −2 Original line number Diff line number Diff line Loading @@ -351,7 +351,7 @@ public class ProtoLogImplTest { ProtoLogData data = readProtoLogSingle(ip); assertNotNull(data); assertEquals(1234, data.mMessageHash.longValue()); assertTrue(before < data.mElapsedTime && data.mElapsedTime < after); assertTrue(before <= data.mElapsedTime && data.mElapsedTime <= after); assertArrayEquals(new String[]{"test"}, data.mStrParams.toArray()); assertArrayEquals(new Long[]{1L, 2L, 3L}, data.mSint64Params.toArray()); assertArrayEquals(new Double[]{0.4, 0.5, 0.6}, data.mDoubleParams.toArray()); Loading @@ -376,7 +376,7 @@ public class ProtoLogImplTest { ProtoLogData data = readProtoLogSingle(ip); assertNotNull(data); assertEquals(1234, data.mMessageHash.longValue()); assertTrue(before < data.mElapsedTime && data.mElapsedTime < after); assertTrue(before <= data.mElapsedTime && data.mElapsedTime <= after); assertArrayEquals(new String[]{"test", "(INVALID PARAMS_MASK) true"}, data.mStrParams.toArray()); assertArrayEquals(new Long[]{1L}, data.mSint64Params.toArray()); Loading tools/protologtool/src/com/android/protolog/tool/CodeUtils.kt +11 −2 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import com.github.javaparser.ast.CompilationUnit import com.github.javaparser.ast.ImportDeclaration import com.github.javaparser.ast.expr.BinaryExpr import com.github.javaparser.ast.expr.Expression import com.github.javaparser.ast.expr.MethodCallExpr import com.github.javaparser.ast.expr.StringLiteralExpr object CodeUtils { Loading @@ -27,8 +28,9 @@ object CodeUtils { * Returns a stable hash of a string. * We reimplement String::hashCode() for readability reasons. */ fun hash(str: String, level: LogLevel): Int { return (level.name + str).map { c -> c.toInt() }.reduce { h, c -> h * 31 + c } fun hash(position: String, messageString: String, logLevel: LogLevel, logGroup: LogGroup): Int { return (position + messageString + logLevel.name + logGroup.name) .map { c -> c.toInt() }.reduce { h, c -> h * 31 + c } } fun isWildcardStaticImported(code: CompilationUnit, className: String): Boolean { Loading Loading @@ -71,4 +73,11 @@ object CodeUtils { "or concatenation of string literals.", expr) } } fun getPositionString(call: MethodCallExpr, fileName: String): String { return when { call.range.isPresent -> "$fileName:${call.range.get().begin.line}" else -> fileName } } } Loading
core/proto/android/server/protolog.proto +1 −1 Original line number Diff line number Diff line Loading @@ -23,7 +23,7 @@ option java_multiple_files = true; /* represents a single log entry */ message ProtoLogMessage { /* log statement identifier, created from message string and log level. */ optional fixed32 message_hash = 1; optional sfixed32 message_hash = 1; /* log time, relative to the elapsed system time clock. */ optional fixed64 elapsed_realtime_nanos = 2; /* string parameters passed to the log call. */ Loading
data/etc/services.core.protolog.json +3 −2 Original line number Diff line number Diff line { "version": "1.0.0", "messages": { "485522692": { "594230385": { "message": "Test completed successfully: %b %d %o %x %e %g %f %% %s.", "level": "ERROR", "group": "TEST_GROUP" "group": "TEST_GROUP", "at": "com\/android\/server\/wm\/ProtoLogGroup.java:94" } }, "groups": { Loading
services/core/java/com/android/server/protolog/ProtoLogImpl.java +47 −39 Original line number Diff line number Diff line Loading @@ -110,6 +110,12 @@ public class ProtoLogImpl { getSingleInstance().log(LogLevel.WTF, group, messageHash, paramsMask, messageString, args); } /** Returns true iff logging is enabled for the given {@code IProtoLogGroup}. */ public static boolean isEnabled(IProtoLogGroup group) { return group.isLogToProto() || (group.isLogToProto() && getSingleInstance().isProtoEnabled()); } private static final int BUFFER_CAPACITY = 1024 * 1024; private static final String LOG_FILENAME = "/data/misc/wmtrace/wm_log.pb"; private static final String VIEWER_CONFIG_FILENAME = "/system/etc/protolog.conf.json.gz"; Loading Loading @@ -222,6 +228,7 @@ public class ProtoLogImpl { os.write(MESSAGE_HASH, messageHash); os.write(ELAPSED_REALTIME_NANOS, SystemClock.elapsedRealtimeNanos()); if (args != null) { int argIndex = 0; ArrayList<Long> longParams = new ArrayList<>(); ArrayList<Double> doubleParams = new ArrayList<>(); Loading Loading @@ -265,6 +272,7 @@ public class ProtoLogImpl { } os.writePackedBool(BOOLEAN_PARAMS, arr); } } os.end(token); mBuffer.add(os); } catch (Exception e) { Loading
services/tests/servicestests/src/com/android/server/protolog/ProtoLogImplTest.java +2 −2 Original line number Diff line number Diff line Loading @@ -351,7 +351,7 @@ public class ProtoLogImplTest { ProtoLogData data = readProtoLogSingle(ip); assertNotNull(data); assertEquals(1234, data.mMessageHash.longValue()); assertTrue(before < data.mElapsedTime && data.mElapsedTime < after); assertTrue(before <= data.mElapsedTime && data.mElapsedTime <= after); assertArrayEquals(new String[]{"test"}, data.mStrParams.toArray()); assertArrayEquals(new Long[]{1L, 2L, 3L}, data.mSint64Params.toArray()); assertArrayEquals(new Double[]{0.4, 0.5, 0.6}, data.mDoubleParams.toArray()); Loading @@ -376,7 +376,7 @@ public class ProtoLogImplTest { ProtoLogData data = readProtoLogSingle(ip); assertNotNull(data); assertEquals(1234, data.mMessageHash.longValue()); assertTrue(before < data.mElapsedTime && data.mElapsedTime < after); assertTrue(before <= data.mElapsedTime && data.mElapsedTime <= after); assertArrayEquals(new String[]{"test", "(INVALID PARAMS_MASK) true"}, data.mStrParams.toArray()); assertArrayEquals(new Long[]{1L}, data.mSint64Params.toArray()); Loading
tools/protologtool/src/com/android/protolog/tool/CodeUtils.kt +11 −2 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import com.github.javaparser.ast.CompilationUnit import com.github.javaparser.ast.ImportDeclaration import com.github.javaparser.ast.expr.BinaryExpr import com.github.javaparser.ast.expr.Expression import com.github.javaparser.ast.expr.MethodCallExpr import com.github.javaparser.ast.expr.StringLiteralExpr object CodeUtils { Loading @@ -27,8 +28,9 @@ object CodeUtils { * Returns a stable hash of a string. * We reimplement String::hashCode() for readability reasons. */ fun hash(str: String, level: LogLevel): Int { return (level.name + str).map { c -> c.toInt() }.reduce { h, c -> h * 31 + c } fun hash(position: String, messageString: String, logLevel: LogLevel, logGroup: LogGroup): Int { return (position + messageString + logLevel.name + logGroup.name) .map { c -> c.toInt() }.reduce { h, c -> h * 31 + c } } fun isWildcardStaticImported(code: CompilationUnit, className: String): Boolean { Loading Loading @@ -71,4 +73,11 @@ object CodeUtils { "or concatenation of string literals.", expr) } } fun getPositionString(call: MethodCallExpr, fileName: String): String { return when { call.range.isPresent -> "$fileName:${call.range.get().begin.line}" else -> fileName } } }