1 /* 2 * Copyright (C) 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.internal.protolog.common; 18 19 import java.util.List; 20 21 /** 22 * Interface for ProtoLog implementations. 23 */ 24 public interface IProtoLog { 25 26 /** 27 * Log a ProtoLog message 28 * @param logLevel Log level of the proto message. 29 * @param group The group this message belongs to. 30 * @param messageHash The hash of the message. 31 * @param paramsMask The parameters mask of the message. 32 * @param args The arguments of the message. 33 */ log(LogLevel logLevel, IProtoLogGroup group, long messageHash, int paramsMask, Object[] args)34 void log(LogLevel logLevel, IProtoLogGroup group, long messageHash, int paramsMask, 35 Object[] args); 36 37 /** 38 * Log a ProtoLog message 39 * @param logLevel Log level of the proto message. 40 * @param group The group this message belongs to. 41 * @param messageString The message string. 42 * @param args The arguments of the message. 43 */ log(LogLevel logLevel, IProtoLogGroup group, String messageString, Object... args)44 void log(LogLevel logLevel, IProtoLogGroup group, String messageString, Object... args); 45 46 /** 47 * Check if ProtoLog is tracing. 48 * @return true iff a ProtoLog tracing session is active. 49 */ isProtoEnabled()50 boolean isProtoEnabled(); 51 52 /** 53 * Start logging log groups to logcat 54 * @param groups Groups to start text logging for 55 * @return status code 56 */ startLoggingToLogcat(String[] groups, ILogger logger)57 int startLoggingToLogcat(String[] groups, ILogger logger); 58 59 /** 60 * Stop logging log groups to logcat 61 * @param groups Groups to start text logging for 62 * @return status code 63 */ stopLoggingToLogcat(String[] groups, ILogger logger)64 int stopLoggingToLogcat(String[] groups, ILogger logger); 65 66 /** 67 * Should return true iff logging is enabled to ProtoLog or to Logcat for this group and level. 68 * @param group ProtoLog group to check for. 69 * @param level ProtoLog level to check for. 70 * @return If we need to log this group and level to either ProtoLog or Logcat. 71 */ isEnabled(IProtoLogGroup group, LogLevel level)72 boolean isEnabled(IProtoLogGroup group, LogLevel level); 73 74 /** 75 * @return an immutable list of the registered ProtoLog groups in this ProtoLog instance. 76 */ getRegisteredGroups()77 List<IProtoLogGroup> getRegisteredGroups(); 78 } 79