Skip to content

Commit

Permalink
add macros with options
Browse files Browse the repository at this point in the history
  • Loading branch information
cpiemontese committed Nov 25, 2024
1 parent 55d83d4 commit 4341b49
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions src/macros/event_with_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,37 @@ macro_rules! event_with_options {
($stat:path, $text:expr) => {
$crate::Datadog::event_with_options($stat.as_ref(), $text, $crate::EMPTY_TAGS, None);
};
($stat:path, $text:expr, $options:expr) => {
$crate::Datadog::event_with_options($stat.as_ref(), $text, $crate::EMPTY_TAGS, Some($options));
};
($stat:expr, $text:expr) => {
$crate::Datadog::event_with_options($stat, $text, $crate::EMPTY_TAGS, None);
};
($stat:expr, $text:expr; $( $key:literal => $value:literal ), *) => {
$crate::Datadog::event_with_options($stat, $text, &[$(::core::concat!($key, ":", $value)), *], None);
($stat:expr, $text:expr, $options:expr) => {
$crate::Datadog::event_with_options($stat, $text, $crate::EMPTY_TAGS, Some($options));
};
($stat:path, $text:expr; $( $key:literal => $value:literal ), *) => {
$crate::Datadog::event_with_options($stat.as_ref(), $text, &[$(::core::concat!($key, ":", $value)), *], None);
};
($stat:expr, $text:expr; $( $key:expr => $value:expr ), *) => {
$crate::Datadog::event_with_options($stat, $text, &[$(::std::format!("{}:{}", $key, $value).as_str()), *], None);
($stat:path, $text:expr, $options:expr; $( $key:literal => $value:literal ), *) => {
$crate::Datadog::event_with_options($stat.as_ref(), $text, &[$(::core::concat!($key, ":", $value)), *], Some(options));
};
($stat:expr, $text:expr; $( $key:literal => $value:literal ), *) => {
$crate::Datadog::event_with_options($stat, $text, &[$(::core::concat!($key, ":", $value)), *], None);
};
($stat:expr, $text:expr, $options:expr; $( $key:literal => $value:literal ), *) => {
$crate::Datadog::event_with_options($stat, $text, &[$(::core::concat!($key, ":", $value)), *], Some(options));
};
($stat:path, $text:expr; $( $key:expr => $value:expr ), *) => {
$crate::Datadog::event_with_options($stat.as_ref(), $text, &[$(::std::format!("{}:{}", $key, $value).as_str()), *], None);
};
($stat:path, $text:expr, $options:expr; $( $key:expr => $value:expr ), *) => {
$crate::Datadog::event_with_options($stat.as_ref(), $text, &[$(::std::format!("{}:{}", $key, $value).as_str()), *], Some($options));
};
($stat:expr, $text:expr; $( $key:expr => $value:expr ), *) => {
$crate::Datadog::event_with_options($stat, $text, &[$(::std::format!("{}:{}", $key, $value).as_str()), *], None);
};
($stat:expr, $text:expr, $options:expr; $( $key:expr => $value:expr ), *) => {
$crate::Datadog::event_with_options($stat, $text, &[$(::std::format!("{}:{}", $key, $value).as_str()), *], Some($options));
};
}

0 comments on commit 4341b49

Please sign in to comment.