2010-07-19 16:05:18 -05:00
|
|
|
#ifndef RUST_LOG_H
|
|
|
|
#define RUST_LOG_H
|
2010-06-23 23:03:09 -05:00
|
|
|
|
2011-04-07 19:37:56 -05:00
|
|
|
#define DLOG(dom, mask, ...) \
|
|
|
|
do { \
|
|
|
|
rust_dom *_dom = dom; \
|
|
|
|
uint32_t _mask = mask; \
|
|
|
|
if ((_dom)->get_log().is_tracing(_mask)) { \
|
|
|
|
(_dom)->log(_mask, __VA_ARGS__); \
|
|
|
|
} \
|
|
|
|
} while(0)
|
|
|
|
#define LOG(task, mask, ...) \
|
2011-04-07 15:05:45 -05:00
|
|
|
DLOG((task)->dom, mask, __VA_ARGS__)
|
2011-04-07 19:37:56 -05:00
|
|
|
#define LOG_I(task, mask, ...) \
|
|
|
|
do { \
|
|
|
|
rust_task *_task = task; \
|
|
|
|
uint32_t _mask = 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(); \
|
|
|
|
} \
|
|
|
|
} while(0)
|
|
|
|
#define LOGPTR(dom, msg, ptrval) \
|
2011-04-07 15:05:45 -05:00
|
|
|
DLOG(dom, rust_log::MEM, "%s 0x%" PRIxPTR, msg, ptrval)
|
|
|
|
|
2010-06-23 23:03:09 -05:00
|
|
|
class rust_dom;
|
2010-07-19 16:05:18 -05:00
|
|
|
class rust_task;
|
|
|
|
|
2010-06-23 23:03:09 -05:00
|
|
|
class rust_log {
|
2010-07-19 16:05:18 -05:00
|
|
|
|
2010-06-23 23:03:09 -05:00
|
|
|
public:
|
|
|
|
rust_log(rust_srv *srv, rust_dom *dom);
|
|
|
|
virtual ~rust_log();
|
|
|
|
|
|
|
|
enum ansi_color {
|
|
|
|
WHITE,
|
|
|
|
RED,
|
|
|
|
LIGHTRED,
|
|
|
|
GREEN,
|
|
|
|
LIGHTGREEN,
|
|
|
|
YELLOW,
|
|
|
|
LIGHTYELLOW,
|
|
|
|
BLUE,
|
|
|
|
LIGHTBLUE,
|
|
|
|
MAGENTA,
|
|
|
|
LIGHTMAGENTA,
|
|
|
|
TEAL,
|
|
|
|
LIGHTTEAL
|
|
|
|
};
|
|
|
|
|
|
|
|
enum log_type {
|
|
|
|
ERR = 0x1,
|
|
|
|
MEM = 0x2,
|
|
|
|
COMM = 0x4,
|
|
|
|
TASK = 0x8,
|
|
|
|
DOM = 0x10,
|
|
|
|
ULOG = 0x20,
|
|
|
|
TRACE = 0x40,
|
|
|
|
DWARF = 0x80,
|
|
|
|
CACHE = 0x100,
|
|
|
|
UPCALL = 0x200,
|
|
|
|
TIMER = 0x400,
|
2010-06-28 20:53:16 -05:00
|
|
|
GC = 0x800,
|
2010-08-12 15:11:49 -05:00
|
|
|
STDLIB = 0x1000,
|
2010-08-18 01:30:10 -05:00
|
|
|
SPECIAL = 0x2000,
|
2010-08-27 20:26:36 -05:00
|
|
|
KERN = 0x4000,
|
2010-10-11 18:40:18 -05:00
|
|
|
BT = 0x8000,
|
2010-06-23 23:03:09 -05:00
|
|
|
ALL = 0xffffffff
|
|
|
|
};
|
|
|
|
|
|
|
|
void indent();
|
|
|
|
void outdent();
|
|
|
|
void reset_indent(uint32_t indent);
|
2010-07-28 01:07:27 -05:00
|
|
|
void trace_ln(uint32_t thread_id, char *prefix, char *message);
|
2010-07-19 16:05:18 -05:00
|
|
|
void trace_ln(rust_task *task, uint32_t type_bits, char *message);
|
2010-07-28 02:11:28 -05:00
|
|
|
void trace_ln(rust_task *task, ansi_color color,
|
|
|
|
uint32_t type_bits, char *message);
|
2010-06-23 23:03:09 -05:00
|
|
|
bool is_tracing(uint32_t type_bits);
|
2010-07-19 16:05:18 -05:00
|
|
|
|
|
|
|
private:
|
|
|
|
rust_srv *_srv;
|
|
|
|
rust_dom *_dom;
|
|
|
|
uint32_t _type_bit_mask;
|
|
|
|
bool _use_labels;
|
|
|
|
bool _use_colors;
|
|
|
|
uint32_t _indent;
|
|
|
|
void trace_ln(rust_task *task, char *message);
|
2010-06-23 23:03:09 -05:00
|
|
|
};
|
|
|
|
|
2011-04-07 15:05:45 -05:00
|
|
|
inline bool
|
|
|
|
rust_log::is_tracing(uint32_t type_bits) {
|
|
|
|
return type_bits & _type_bit_mask;
|
|
|
|
}
|
|
|
|
|
2011-04-18 09:18:55 -05:00
|
|
|
void update_log_settings(void* crate_map, char* settings);
|
|
|
|
|
2010-07-19 16:05:18 -05:00
|
|
|
#endif /* RUST_LOG_H */
|