Loading tools/protologtool/src/com/android/protolog/tool/LogLevel.kt→core/java/com/android/internal/protolog/common/LogLevel.java +26 −0 Original line number Diff line number Diff line /* * Copyright (C) 2019 The Android Open Source Project * Copyright (C) 2023 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. Loading @@ -14,25 +14,13 @@ * limitations under the License. */ package com.android.protolog.tool package com.android.internal.protolog.common; import com.github.javaparser.ast.Node public enum LogLevel { DEBUG("d"), VERBOSE("v"), INFO("i"), WARN("w"), ERROR("e"), WTF("wtf"); enum class LogLevel { DEBUG, VERBOSE, INFO, WARN, ERROR, WTF; companion object { fun getLevelForMethodName(name: String, node: Node, context: ParsingContext): LogLevel { return when (name) { "d" -> DEBUG "v" -> VERBOSE "i" -> INFO "w" -> WARN "e" -> ERROR "wtf" -> WTF else -> throw InvalidProtoLogCallException("Unknown log level $name in $node", context) } } public final String shortCode; LogLevel(String shortCode) { this.shortCode = shortCode; } } tools/protologtool/src/com/android/protolog/tool/CodeUtils.kt +1 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.protolog.tool import com.android.internal.protolog.common.LogLevel import com.github.javaparser.ast.CompilationUnit import com.github.javaparser.ast.ImportDeclaration import com.github.javaparser.ast.expr.BinaryExpr Loading tools/protologtool/src/com/android/protolog/tool/ProtoLogCallProcessor.kt +18 −1 Original line number Diff line number Diff line Loading @@ -16,7 +16,9 @@ package com.android.protolog.tool import com.android.internal.protolog.common.LogLevel import com.github.javaparser.ast.CompilationUnit import com.github.javaparser.ast.Node import com.github.javaparser.ast.expr.Expression import com.github.javaparser.ast.expr.FieldAccessExpr import com.github.javaparser.ast.expr.MethodCallExpr Loading Loading @@ -105,9 +107,24 @@ open class ProtoLogCallProcessor( "- not a ProtoLogGroup enum member: $call", context) } callVisitor?.processCall(call, messageString, LogLevel.getLevelForMethodName( callVisitor?.processCall(call, messageString, getLevelForMethodName( call.name.toString(), call, context), groupMap.getValue(groupName)) } return code } companion object { fun getLevelForMethodName(name: String, node: Node, context: ParsingContext): LogLevel { return when (name) { "d" -> LogLevel.DEBUG "v" -> LogLevel.VERBOSE "i" -> LogLevel.INFO "w" -> LogLevel.WARN "e" -> LogLevel.ERROR "wtf" -> LogLevel.WTF else -> throw InvalidProtoLogCallException("Unknown log level $name in $node", context) } } } } tools/protologtool/src/com/android/protolog/tool/ProtoLogCallVisitor.kt +1 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.protolog.tool import com.android.internal.protolog.common.LogLevel import com.github.javaparser.ast.expr.MethodCallExpr interface ProtoLogCallVisitor { Loading tools/protologtool/src/com/android/protolog/tool/SourceTransformer.kt +1 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.protolog.tool import com.android.internal.protolog.common.LogDataType import com.android.internal.protolog.common.LogLevel import com.github.javaparser.StaticJavaParser import com.github.javaparser.ast.CompilationUnit import com.github.javaparser.ast.NodeList Loading Loading
tools/protologtool/src/com/android/protolog/tool/LogLevel.kt→core/java/com/android/internal/protolog/common/LogLevel.java +26 −0 Original line number Diff line number Diff line /* * Copyright (C) 2019 The Android Open Source Project * Copyright (C) 2023 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. Loading @@ -14,25 +14,13 @@ * limitations under the License. */ package com.android.protolog.tool package com.android.internal.protolog.common; import com.github.javaparser.ast.Node public enum LogLevel { DEBUG("d"), VERBOSE("v"), INFO("i"), WARN("w"), ERROR("e"), WTF("wtf"); enum class LogLevel { DEBUG, VERBOSE, INFO, WARN, ERROR, WTF; companion object { fun getLevelForMethodName(name: String, node: Node, context: ParsingContext): LogLevel { return when (name) { "d" -> DEBUG "v" -> VERBOSE "i" -> INFO "w" -> WARN "e" -> ERROR "wtf" -> WTF else -> throw InvalidProtoLogCallException("Unknown log level $name in $node", context) } } public final String shortCode; LogLevel(String shortCode) { this.shortCode = shortCode; } }
tools/protologtool/src/com/android/protolog/tool/CodeUtils.kt +1 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.protolog.tool import com.android.internal.protolog.common.LogLevel import com.github.javaparser.ast.CompilationUnit import com.github.javaparser.ast.ImportDeclaration import com.github.javaparser.ast.expr.BinaryExpr Loading
tools/protologtool/src/com/android/protolog/tool/ProtoLogCallProcessor.kt +18 −1 Original line number Diff line number Diff line Loading @@ -16,7 +16,9 @@ package com.android.protolog.tool import com.android.internal.protolog.common.LogLevel import com.github.javaparser.ast.CompilationUnit import com.github.javaparser.ast.Node import com.github.javaparser.ast.expr.Expression import com.github.javaparser.ast.expr.FieldAccessExpr import com.github.javaparser.ast.expr.MethodCallExpr Loading Loading @@ -105,9 +107,24 @@ open class ProtoLogCallProcessor( "- not a ProtoLogGroup enum member: $call", context) } callVisitor?.processCall(call, messageString, LogLevel.getLevelForMethodName( callVisitor?.processCall(call, messageString, getLevelForMethodName( call.name.toString(), call, context), groupMap.getValue(groupName)) } return code } companion object { fun getLevelForMethodName(name: String, node: Node, context: ParsingContext): LogLevel { return when (name) { "d" -> LogLevel.DEBUG "v" -> LogLevel.VERBOSE "i" -> LogLevel.INFO "w" -> LogLevel.WARN "e" -> LogLevel.ERROR "wtf" -> LogLevel.WTF else -> throw InvalidProtoLogCallException("Unknown log level $name in $node", context) } } } }
tools/protologtool/src/com/android/protolog/tool/ProtoLogCallVisitor.kt +1 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.protolog.tool import com.android.internal.protolog.common.LogLevel import com.github.javaparser.ast.expr.MethodCallExpr interface ProtoLogCallVisitor { Loading
tools/protologtool/src/com/android/protolog/tool/SourceTransformer.kt +1 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.protolog.tool import com.android.internal.protolog.common.LogDataType import com.android.internal.protolog.common.LogLevel import com.github.javaparser.StaticJavaParser import com.github.javaparser.ast.CompilationUnit import com.github.javaparser.ast.NodeList Loading