1 /*
2  * Copyright (C) 2020 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.statusbar.notification.collection.coalescer
18 
19 import com.android.systemui.log.dagger.NotificationLog
20 import com.android.systemui.log.LogBuffer
21 import com.android.systemui.log.core.LogLevel
22 import javax.inject.Inject
23 
24 class GroupCoalescerLogger @Inject constructor(
25     @NotificationLog private val buffer: LogBuffer
26 ) {
logEventCoalescednull27     fun logEventCoalesced(key: String) {
28         buffer.log(TAG, LogLevel.INFO, {
29             str1 = key
30         }, {
31             "COALESCED: $str1"
32         })
33     }
34 
logEmitBatchnull35     fun logEmitBatch(groupKey: String, batchSize: Int, batchAgeMs: Long) {
36         buffer.log(TAG, LogLevel.DEBUG, {
37             str1 = groupKey
38             int1 = batchSize
39             long1 = batchAgeMs
40         }, {
41             "Emitting batch for group $str1 size=$int1 age=${long1}ms"
42         })
43     }
44 
logEarlyEmitnull45     fun logEarlyEmit(modifiedKey: String, groupKey: String) {
46         buffer.log(TAG, LogLevel.DEBUG, {
47             str1 = modifiedKey
48             str2 = groupKey
49         }, {
50             "Modification of notif $str1 triggered early emit of batched group $str2"
51         })
52     }
53 
logMaxBatchTimeoutnull54     fun logMaxBatchTimeout(modifiedKey: String, groupKey: String) {
55         buffer.log(TAG, LogLevel.INFO, {
56             str1 = modifiedKey
57             str2 = groupKey
58         }, {
59             "Modification of notif $str1 triggered TIMEOUT emit of batched group $str2"
60         })
61     }
62 
logMissingRankingnull63     fun logMissingRanking(forKey: String) {
64         buffer.log(TAG, LogLevel.WARNING, {
65             str1 = forKey
66         }, {
67             "RankingMap is missing an entry for coalesced notification $str1"
68         })
69     }
70 }
71 
72 private const val TAG = "GroupCoalescer"