notify: additional logging when sending a notification

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
This commit is contained in:
Lukas Wagner 2023-07-20 16:31:51 +02:00 committed by Wolfgang Bumiller
parent 2756c11c2f
commit 9b726bb072

View File

@ -305,9 +305,12 @@ impl Bus {
if let Some(group) = self.groups.get(endpoint_or_group) { if let Some(group) = self.groups.get(endpoint_or_group) {
if !Bus::check_filter(&mut filter_matcher, group.filter.as_deref()) { if !Bus::check_filter(&mut filter_matcher, group.filter.as_deref()) {
log::info!("skipped target '{endpoint_or_group}', filter did not match");
return; return;
} }
log::info!("target '{endpoint_or_group}' is a group, notifying all members...");
for endpoint in &group.endpoint { for endpoint in &group.endpoint {
self.send_via_single_endpoint(endpoint, notification, &mut filter_matcher); self.send_via_single_endpoint(endpoint, notification, &mut filter_matcher);
} }
@ -339,19 +342,23 @@ impl Bus {
filter_matcher: &mut FilterMatcher, filter_matcher: &mut FilterMatcher,
) { ) {
if let Some(endpoint) = self.endpoints.get(endpoint) { if let Some(endpoint) = self.endpoints.get(endpoint) {
let name = endpoint.name();
if !Bus::check_filter(filter_matcher, endpoint.filter()) { if !Bus::check_filter(filter_matcher, endpoint.filter()) {
log::info!("skipped target '{name}', filter did not match");
return; return;
} }
if let Err(e) = endpoint.send(notification) { match endpoint.send(notification) {
// Only log on errors, do not propagate fail to the caller. Ok(_) => {
log::error!( log::info!("notified via target `{name}`");
"could not notify via target `{name}`: {e}", }
name = endpoint.name() Err(e) => {
); // Only log on errors, do not propagate fail to the caller.
log::error!("could not notify via target `{name}`: {e}");
}
} }
} else { } else {
log::error!("could not notify via endpoint '{endpoint}', it does not exist"); log::error!("could not notify via target '{endpoint}', it does not exist");
} }
} }