From 9a7576fe2cdd169313b5e25be6bf485407adb496 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 7 Apr 2011 22:05:45 +0200 Subject: Move to macro-based logging checks in the C++ code No functions should be called for log statements that turn out to be inactive. --- src/rt/rust_log.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/rt/rust_log.h') diff --git a/src/rt/rust_log.h b/src/rt/rust_log.h index 59aa504f..8d3d4bcb 100644 --- a/src/rt/rust_log.h +++ b/src/rt/rust_log.h @@ -1,6 +1,21 @@ #ifndef RUST_LOG_H #define RUST_LOG_H +#define DLOG(dom, mask, ...) \ + if ((dom)->get_log().is_tracing(mask)) { \ + (dom)->log(mask, __VA_ARGS__); \ + } else +#define LOG(task, mask, ...) \ + DLOG((task)->dom, mask, __VA_ARGS__) +#define LOG_I(task, mask, ...) \ + if ((task)->dom->get_log().is_tracing(mask)) { \ + (task)->dom->get_log().reset_indent(0); \ + (task)->dom->log(mask, __VA_ARGS__); \ + (task)->dom->get_log().indent(); \ + } else +#define LOGPTR(dom, msg, ptrval) \ + DLOG(dom, rust_log::MEM, "%s 0x%" PRIxPTR, msg, ptrval) + class rust_dom; class rust_task; @@ -65,4 +80,9 @@ private: void trace_ln(rust_task *task, char *message); }; +inline bool +rust_log::is_tracing(uint32_t type_bits) { + return type_bits & _type_bit_mask; +} + #endif /* RUST_LOG_H */ -- cgit v1.2.3