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.keyguard.logging 18 19 import com.android.systemui.log.LogBuffer 20 import com.android.systemui.log.core.LogLevel 21 import com.android.systemui.log.dagger.ScrimLog 22 import com.google.errorprone.annotations.CompileTimeConstant 23 import javax.inject.Inject 24 25 /** 26 * A logger to log scrim state. 27 * 28 * To enable logcat echoing for this buffer use this command: 29 * ``` 30 * $ adb shell cmd statusbar echo -b ScrimLog:VERBOSE 31 * ``` 32 */ 33 class ScrimLogger 34 @Inject 35 constructor( 36 @ScrimLog val buffer: LogBuffer, 37 ) { 38 companion object { 39 val TAG = ScrimLogger::class.simpleName!! 40 } 41 dnull42 fun d( 43 tag: String, 44 @CompileTimeConstant msg: String, 45 arg: Any, 46 ) = log("$tag::$TAG", LogLevel.DEBUG, msg, arg) 47 48 fun log( 49 tag: String, 50 level: LogLevel, 51 @CompileTimeConstant msg: String, 52 arg: Any, 53 ) = 54 buffer.log( 55 tag, 56 level, 57 { 58 str1 = msg 59 str2 = arg.toString() 60 }, <lambda>null61 { "$str1: $str2" } 62 ) 63 } 64