Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1664ccbb authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Support unprocessed files when Perfetto protologging is not enabled" into main

parents 1edbd598 5004cd01
Loading
Loading
Loading
Loading
+15 −11
Original line number Diff line number Diff line
@@ -40,6 +40,8 @@ import java.util.List;
 */
@Deprecated
public class LogcatOnlyProtoLogImpl implements IProtoLog {
    private static final String LOG_TAG = LogcatOnlyProtoLogImpl.class.getName();

    @Override
    public void log(LogLevel logLevel, IProtoLogGroup group, long messageHash, int paramsMask,
            Object[] args) {
@@ -48,11 +50,12 @@ public class LogcatOnlyProtoLogImpl implements IProtoLog {

    @Override
    public void log(LogLevel logLevel, IProtoLogGroup group, String messageString, Object[] args) {
        if (REQUIRE_PROTOLOGTOOL) {
            throw new RuntimeException(
                    "REQUIRE_PROTOLOGTOOL not set to false before the first log call.");
        if (REQUIRE_PROTOLOGTOOL && group.isLogToProto()) {
            Log.w(LOG_TAG, "ProtoLog message not processed. Failed to log it to proto. "
                    + "Logging it below to logcat instead.");
        }

        if (group.isLogToLogcat() || group.isLogToProto()) {
            String formattedString = TextUtils.formatSimple(messageString, args);
            switch (logLevel) {
                case VERBOSE -> Log.v(group.getTag(), formattedString);
@@ -63,6 +66,7 @@ public class LogcatOnlyProtoLogImpl implements IProtoLog {
                case WTF -> Log.wtf(group.getTag(), formattedString);
            }
        }
    }

    @Override
    public boolean isProtoEnabled() {
+3 −2
Original line number Diff line number Diff line
@@ -63,6 +63,9 @@ public class ProtoLog {
     * @param groups The ProtoLog groups that will be used in the process.
     */
    public static void init(IProtoLogGroup... groups) {
        // These tracing instances are only used when we cannot or do not preprocess the source
        // files to extract out the log strings. Otherwise, the trace calls are replaced with calls
        // directly to the generated tracing implementations.
        if (android.tracing.Flags.perfettoProtologTracing()) {
            synchronized (sInitLock) {
                if (sProtoLogInstance != null) {
@@ -76,8 +79,6 @@ public class ProtoLog {
                sProtoLogInstance = new PerfettoProtoLogImpl(groups);
            }
        } else {
            // The first call to ProtoLog is likely to flip REQUIRE_PROTOLOGTOOL, which is when this
            // static block will be executed before REQUIRE_PROTOLOGTOOL is actually set.
            sProtoLogInstance = new LogcatOnlyProtoLogImpl();
        }
    }