From a3b7c19204b8a1582922f5832b5e06d6a1a3a999 Mon Sep 17 00:00:00 2001 From: Roman Gilg Date: Wed, 26 Feb 2020 11:23:26 +0100 Subject: [PATCH] Log layer priority only on change Similar to reuse log print debug information only when the priority of a layer changes not whenever priority gets updated but without change. Otherwise the debug log is spammed (depending on LIFTOFF_PRIORITY_PERIOD). --- layer.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/layer.c b/layer.c index 10a18f7..edcf514 100644 --- a/layer.c +++ b/layer.c @@ -147,6 +147,17 @@ void layer_mark_clean(struct liftoff_layer *layer) } } +static void log_priority(struct liftoff_layer *layer) +{ + if (layer->current_priority == layer->pending_priority) { + return; + } + + liftoff_log(LIFTOFF_DEBUG, "Layer %p priority change: %d -> %d", + (void *)layer, layer->current_priority, + layer->pending_priority); +} + void layer_update_priority(struct liftoff_layer *layer, bool make_current) { struct liftoff_layer_property *prop; @@ -158,10 +169,9 @@ void layer_update_priority(struct liftoff_layer *layer, bool make_current) { } if (make_current) { + log_priority(layer); layer->current_priority = layer->pending_priority; layer->pending_priority = 0; - liftoff_log(LIFTOFF_DEBUG, "Layer %p has priority %d", - (void *)layer, layer->current_priority); } }