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.keyguard.shared.model.TransitionStep
20 import com.android.systemui.log.LogBuffer
21 import com.android.systemui.log.core.LogLevel
22 import com.android.systemui.log.dagger.KeyguardTransitionAnimationLog
23 import javax.inject.Inject
24 
25 private const val TAG = "KeyguardTransitionAnimationLog"
26 
27 /**
28  * Generic logger for keyguard that's wrapping [LogBuffer]. This class should be used for adding
29  * temporary logs or logs for smaller classes when creating whole new [LogBuffer] wrapper might be
30  * an overkill.
31  */
32 class KeyguardTransitionAnimationLogger
33 @Inject
34 constructor(
35     @KeyguardTransitionAnimationLog val buffer: LogBuffer,
36 ) {
37     @JvmOverloads
logCreatenull38     fun logCreate(
39         name: String? = null,
40         start: Float,
41     ) {
42         if (name == null) return
43 
44         buffer.log(
45             TAG,
46             LogLevel.DEBUG,
47             {
48                 str1 = name
49                 str2 = "$start"
50             },
51             { "[$str1] starts at: $str2" }
52         )
53     }
54 
55     @JvmOverloads
logTransitionStepnull56     fun logTransitionStep(
57         name: String? = null,
58         step: TransitionStep,
59         value: Float? = null,
60     ) {
61         if (name == null) return
62 
63         buffer.log(
64             TAG,
65             LogLevel.DEBUG,
66             {
67                 str1 = "[$name][${step.transitionState}]"
68                 str2 = "${step.value}"
69                 str3 = "$value"
70             },
71             { "$str1 transitionStep=$str2, animationValue=$str3" }
72         )
73     }
74 }
75