From 5433e10b182fff115cc40f768330e6562cebca88 Mon Sep 17 00:00:00 2001 From: Jeff DeCew Date: Wed, 18 May 2022 16:04:32 +0000 Subject: [PATCH] Reduce logs from NodeSpecBuilder/NotificationEntryMgr These logs are not currently useful, and are taking up a large portion of our NotifLog buffer, making it significantly less likely that we have the logs we need to diagnose issues. Test: dumpsysui NotifHeadsUpLog NotifLog Fixes: 236140753 Change-Id: I32058e004fc07b72763e9457f5d19a79d4ecf9b5 --- .../NotificationEntryManagerLogger.kt | 30 ++++++++++++++----- .../render/NodeSpecBuilderLogger.kt | 6 +++- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManagerLogger.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManagerLogger.kt index 2397005a1a61a..52dcf02e3a198 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManagerLogger.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManagerLogger.kt @@ -17,18 +17,32 @@ package com.android.systemui.statusbar.notification import com.android.systemui.log.LogBuffer +import com.android.systemui.log.LogLevel import com.android.systemui.log.LogLevel.DEBUG import com.android.systemui.log.LogLevel.INFO import com.android.systemui.log.LogLevel.WARNING +import com.android.systemui.log.LogMessage import com.android.systemui.log.dagger.NotificationLog +import com.android.systemui.util.Compile import javax.inject.Inject /** Logger for [NotificationEntryManager]. */ class NotificationEntryManagerLogger @Inject constructor( + notifPipelineFlags: NotifPipelineFlags, @NotificationLog private val buffer: LogBuffer ) { + private val devLoggingEnabled by lazy { notifPipelineFlags.isDevLoggingEnabled() } + + private inline fun devLog( + level: LogLevel, + initializer: LogMessage.() -> Unit, + noinline printer: LogMessage.() -> String + ) { + if (Compile.IS_DEBUG && devLoggingEnabled) buffer.log(TAG, level, initializer, printer) + } + fun logNotifAdded(key: String) { - buffer.log(TAG, INFO, { + devLog(INFO, { str1 = key }, { "NOTIF ADDED $str1" @@ -36,7 +50,7 @@ class NotificationEntryManagerLogger @Inject constructor( } fun logNotifUpdated(key: String) { - buffer.log(TAG, INFO, { + devLog(INFO, { str1 = key }, { "NOTIF UPDATED $str1" @@ -44,7 +58,7 @@ class NotificationEntryManagerLogger @Inject constructor( } fun logInflationAborted(key: String, status: String, reason: String) { - buffer.log(TAG, DEBUG, { + devLog(DEBUG, { str1 = key str2 = status str3 = reason @@ -54,7 +68,7 @@ class NotificationEntryManagerLogger @Inject constructor( } fun logNotifInflated(key: String, isNew: Boolean) { - buffer.log(TAG, DEBUG, { + devLog(DEBUG, { str1 = key bool1 = isNew }, { @@ -63,7 +77,7 @@ class NotificationEntryManagerLogger @Inject constructor( } fun logRemovalIntercepted(key: String) { - buffer.log(TAG, INFO, { + devLog(INFO, { str1 = key }, { "NOTIF REMOVE INTERCEPTED for $str1" @@ -71,7 +85,7 @@ class NotificationEntryManagerLogger @Inject constructor( } fun logLifetimeExtended(key: String, extenderName: String, status: String) { - buffer.log(TAG, INFO, { + devLog(INFO, { str1 = key str2 = extenderName str3 = status @@ -81,7 +95,7 @@ class NotificationEntryManagerLogger @Inject constructor( } fun logNotifRemoved(key: String, removedByUser: Boolean) { - buffer.log(TAG, INFO, { + devLog(INFO, { str1 = key bool1 = removedByUser }, { @@ -90,7 +104,7 @@ class NotificationEntryManagerLogger @Inject constructor( } fun logFilterAndSort(reason: String) { - buffer.log(TAG, INFO, { + devLog(INFO, { str1 = reason }, { "FILTER AND SORT reason=$str1" diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/render/NodeSpecBuilderLogger.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/render/NodeSpecBuilderLogger.kt index 3501b44a2c2e2..38e3d496a60ce 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/render/NodeSpecBuilderLogger.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/render/NodeSpecBuilderLogger.kt @@ -19,20 +19,24 @@ package com.android.systemui.statusbar.notification.collection.render import com.android.systemui.log.LogBuffer import com.android.systemui.log.LogLevel import com.android.systemui.log.dagger.NotificationLog +import com.android.systemui.statusbar.notification.NotifPipelineFlags import com.android.systemui.statusbar.notification.collection.listbuilder.NotifSection import com.android.systemui.util.Compile import javax.inject.Inject class NodeSpecBuilderLogger @Inject constructor( + notifPipelineFlags: NotifPipelineFlags, @NotificationLog private val buffer: LogBuffer ) { + private val devLoggingEnabled by lazy { notifPipelineFlags.isDevLoggingEnabled() } + fun logBuildNodeSpec( oldSections: Set, newHeaders: Map, newCounts: Map, newSectionOrder: List ) { - if (!Compile.IS_DEBUG) + if (!(Compile.IS_DEBUG && devLoggingEnabled)) return buffer.log(TAG, LogLevel.DEBUG, {