[CRIU] [PATCH 1/3] log: Add pr_quelled helper
Cyrill Gorcunov
gorcunov at openvz.org
Tue Sep 2 12:27:19 PDT 2014
If we need to check if current loglevel will suppress
our messagess (say you need to run pr_debug in a cycle)
we can use this helper to eliminate unneded calls.
Like
if (!pr_quelled(LOG_DEBUG)) {
... do something specific to LOG_DEBUG ...
}
Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
include/log.h | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/include/log.h b/include/log.h
index 65a65ac7dd5a..45303de550cd 100644
--- a/include/log.h
+++ b/include/log.h
@@ -27,4 +27,9 @@ extern int write_pidfile(int pid);
extern void print_data(unsigned long addr, unsigned char *data, size_t size);
extern void print_image_data(int fd, unsigned int length, int show);
+static inline int pr_quelled(unsigned int loglevel)
+{
+ return log_get_loglevel() < loglevel && loglevel != LOG_MSG;
+}
+
#endif /* __CR_LOG_H__ */
--
1.9.3
More information about the CRIU
mailing list