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.LogBuffer
20 import com.android.systemui.log.LogLevel
21 import com.android.systemui.log.dagger.NotificationLog
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) {
36         buffer.log(TAG, LogLevel.DEBUG, {
37             str1 = groupKey
38         }, {
39             "Emitting event batch for group $str1"
40         })
41     }
42 
logEarlyEmitnull43     fun logEarlyEmit(modifiedKey: String, groupKey: String) {
44         buffer.log(TAG, LogLevel.DEBUG, {
45             str1 = modifiedKey
46             str2 = groupKey
47         }, {
48             "Modification of notif $str1 triggered early emit of batched group $str2"
49         })
50     }
51 
logMaxBatchTimeoutnull52     fun logMaxBatchTimeout(modifiedKey: String, groupKey: String) {
53         buffer.log(TAG, LogLevel.INFO, {
54             str1 = modifiedKey
55             str2 = groupKey
56         }, {
57             "Modification of notif $str1 triggered TIMEOUT emit of batched group $str2"
58         })
59     }
60 
logMissingRankingnull61     fun logMissingRanking(forKey: String) {
62         buffer.log(TAG, LogLevel.WARNING, {
63             str1 = forKey
64         }, {
65             "RankingMap is missing an entry for coalesced notification $str1"
66         })
67     }
68 }
69 
70 private const val TAG = "GroupCoalescer"