Signed-off-by: Miroslav Lichvar <[email protected]>
---
 print.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/print.h b/print.h
index f5ed248..6d7aa94 100644
--- a/print.h
+++ b/print.h
@@ -44,4 +44,21 @@ void print_set_verbose(int value);
 #define pr_info(x...)    print(LOG_INFO, x)
 #define pr_debug(x...)   print(LOG_DEBUG, x)
 
+#define PRINT_RL(l, i, x...) \
+       do { \
+               static time_t last = -i; \
+               if (!rate_limited(i, &last)) \
+                       print(l, x); \
+       } while (0);
+
+/* Rate limited versions */
+#define pl_emerg(i, x...)   PRINT_RL(LOG_EMERG, i, x)
+#define pl_alert(i, x...)   PRINT_RL(LOG_ALERT, i, x)
+#define pl_crit(i, x...)    PRINT_RL(LOG_CRIT, i, x)
+#define pl_err(i, x...)     PRINT_RL(LOG_ERR, i, x)
+#define pl_warning(i, x...) PRINT_RL(LOG_WARNING, i, x)
+#define pl_notice(i, x...)  PRINT_RL(LOG_NOTICE, i, x)
+#define pl_info(i, x...)    PRINT_RL(LOG_INFO, i, x)
+#define pl_debug(i, x...)   PRINT_RL(LOG_DEBUG, i, x)
+
 #endif
-- 
2.1.0


------------------------------------------------------------------------------
Monitor Your Dynamic Infrastructure at Any Scale With Datadog!
Get real-time metrics from all of your servers, apps and tools
in one place.
SourceForge users - Click here to start your Free Trial of Datadog now!
http://pubads.g.doubleclick.net/gampad/clk?id=241902991&iu=/4140
_______________________________________________
Linuxptp-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to