1// Copyright 2024 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
45/// Macro wrapper for logging simple events (occurrence, integer, histogram, string)
6/// and log a warning when the status is not Ok.
7// TODO(339221340): remove these allows once the skeleton has a few uses
8#[allow(unused)]
9macro_rules! log_cobalt_1dot1 {
10 ($cobalt_proxy:expr, $method_name:ident, $metric_id:expr, $value:expr, $event_codes:expr $(,)?) => {{
11let status = $cobalt_proxy.$method_name($metric_id, $value, $event_codes).await;
12match status {
13Ok(Ok(())) => (),
14Ok(Err(e)) => log::info!("Failed logging metric: {}, error: {:?}", $metric_id, e),
15Err(e) => log::info!("Failed logging metric: {}, error: {}", $metric_id, e),
16 }
17 }};
18}
1920macro_rules! log_cobalt_1dot1_batch {
21 ($cobalt_proxy:expr, $events:expr, $context:expr $(,)?) => {{
22let status = $cobalt_proxy.log_metric_events($events).await;
23match status {
24Ok(Ok(())) => (),
25Ok(Err(e)) => {
26log::info!("Failed logging batch metrics, context: {}, error: {:?}", $context, e);
27 }
28Err(e) => {
29log::info!("Failed logging batch metrics, context: {}, error: {}", $context, e)
30 }
31 }
32 }};
33}
3435// TODO(339221340): remove these allows once the skeleton has a few uses
36#[allow(unused)]
37pub(crate) use {log_cobalt_1dot1, log_cobalt_1dot1_batch};