diff options
| author | Marijn Haverbeke <[email protected]> | 2011-04-07 22:05:45 +0200 |
|---|---|---|
| committer | Graydon Hoare <[email protected]> | 2011-04-07 15:15:30 -0700 |
| commit | 9a7576fe2cdd169313b5e25be6bf485407adb496 (patch) | |
| tree | 36f5c9a5baaae95be1fb3cdc9b5b76814b08e803 /src/rt/rust_log.h | |
| parent | rustc: Pointer cast when autodereferencing boxed tag types (diff) | |
| download | rust-9a7576fe2cdd169313b5e25be6bf485407adb496.tar.xz rust-9a7576fe2cdd169313b5e25be6bf485407adb496.zip | |
Move to macro-based logging checks in the C++ code
No functions should be called for log statements that turn out to be
inactive.
Diffstat (limited to 'src/rt/rust_log.h')
| -rw-r--r-- | src/rt/rust_log.h | 20 |
1 files changed, 20 insertions, 0 deletions
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 */ |