1 /* 2 * Copyright (C) 2024 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.systemui.media.controls.domain.pipeline 18 19 import com.android.internal.logging.InstanceId 20 import com.android.systemui.dagger.SysUISingleton 21 import com.android.systemui.log.LogBuffer 22 import com.android.systemui.log.core.LogLevel 23 import com.android.systemui.log.dagger.MediaLoadingLog 24 import javax.inject.Inject 25 26 /** A buffered log for media loading events. */ 27 @SysUISingleton 28 class MediaLoadingLogger @Inject constructor(@MediaLoadingLog private val buffer: LogBuffer) { 29 logMediaLoadednull30 fun logMediaLoaded(instanceId: InstanceId, active: Boolean, reason: String) { 31 buffer.log( 32 TAG, 33 LogLevel.DEBUG, 34 { 35 str1 = instanceId.toString() 36 bool1 = active 37 str2 = reason 38 }, 39 { "add media $str1, active: $bool1, reason: $str2" } 40 ) 41 } 42 logMediaRemovednull43 fun logMediaRemoved(instanceId: InstanceId, reason: String) { 44 buffer.log( 45 TAG, 46 LogLevel.DEBUG, 47 { 48 str1 = instanceId.toString() 49 str2 = reason 50 }, 51 { "removing media $str1, reason: $str2" } 52 ) 53 } 54 logRecommendationLoadednull55 fun logRecommendationLoaded(key: String, isActive: Boolean, reason: String) { 56 buffer.log( 57 TAG, 58 LogLevel.DEBUG, 59 { 60 str1 = key 61 bool1 = isActive 62 str2 = reason 63 }, 64 { "add recommendation $str1, active $bool1, reason: $str2" } 65 ) 66 } 67 logRecommendationRemovednull68 fun logRecommendationRemoved(key: String, immediately: Boolean, reason: String) { 69 buffer.log( 70 TAG, 71 LogLevel.DEBUG, 72 { 73 str1 = key 74 bool1 = immediately 75 str2 = reason 76 }, 77 { "removing recommendation $str1, immediate=$bool1, reason: $str2" } 78 ) 79 } 80 81 companion object { 82 private const val TAG = "MediaLoadingLog" 83 } 84 } 85