1 /** 2 * Copyright (C) 2022 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.server.broadcastradio.hal2; 18 19 import android.util.IndentingPrintWriter; 20 import android.util.LocalLog; 21 import android.util.Log; 22 import android.util.Slog; 23 24 final class RadioEventLogger { 25 private final String mTag; 26 private final LocalLog mEventLogger; 27 RadioEventLogger(String tag, int loggerQueueSize)28 RadioEventLogger(String tag, int loggerQueueSize) { 29 mTag = tag; 30 mEventLogger = new LocalLog(loggerQueueSize); 31 } 32 logRadioEvent(String logFormat, Object... args)33 void logRadioEvent(String logFormat, Object... args) { 34 String log = String.format(logFormat, args); 35 mEventLogger.log(log); 36 if (Log.isLoggable(mTag, Log.DEBUG)) { 37 Slog.d(mTag, log); 38 } 39 } 40 dump(IndentingPrintWriter pw)41 void dump(IndentingPrintWriter pw) { 42 mEventLogger.dump(pw); 43 } 44 } 45