2011-06-28 14:15:41 -05:00
|
|
|
// -*- c++ -*-
|
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-19 05:21:57 -05:00
|
|
|
const uint32_t log_err = 0;
|
|
|
|
const uint32_t log_note = 1;
|
|
|
|
|
|
|
|
#define LOG(task, field, ...) \
|
2011-06-28 14:15:41 -05:00
|
|
|
DLOG_LVL(log_note, task, task->sched, field, __VA_ARGS__)
|
2011-04-19 05:21:57 -05:00
|
|
|
#define LOG_ERR(task, field, ...) \
|
2011-06-28 14:15:41 -05:00
|
|
|
DLOG_LVL(log_err, task, task->sched, field, __VA_ARGS__)
|
|
|
|
#define DLOG(sched, field, ...) \
|
|
|
|
DLOG_LVL(log_note, NULL, sched, field, __VA_ARGS__)
|
|
|
|
#define DLOG_ERR(sched, field, ...) \
|
|
|
|
DLOG_LVL(log_err, NULL, sched, field, __VA_ARGS__)
|
|
|
|
#define LOGPTR(sched, msg, ptrval) \
|
|
|
|
DLOG_LVL(log_note, NULL, sched, mem, "%s 0x%" PRIxPTR, msg, ptrval)
|
|
|
|
#define DLOG_LVL(lvl, task, sched, field, ...) \
|
2011-04-19 05:21:57 -05:00
|
|
|
do { \
|
2011-06-28 14:15:41 -05:00
|
|
|
rust_scheduler* _d_ = sched; \
|
2011-04-19 05:21:57 -05:00
|
|
|
if (log_rt_##field >= lvl && _d_->log_lvl >= lvl) { \
|
|
|
|
_d_->log(task, lvl, __VA_ARGS__); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
2011-04-07 15:05:45 -05:00
|
|
|
|
2011-06-28 14:15:41 -05:00
|
|
|
struct rust_scheduler;
|
2011-05-08 23:08:43 -05:00
|
|
|
struct rust_task;
|
2010-07-19 16:05:18 -05:00
|
|
|
|
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:
|
2011-06-28 14:15:41 -05:00
|
|
|
rust_log(rust_srv *srv, rust_scheduler *sched);
|
2010-06-23 23:03:09 -05:00
|
|
|
virtual ~rust_log();
|
|
|
|
|
|
|
|
enum ansi_color {
|
|
|
|
WHITE,
|
|
|
|
RED,
|
|
|
|
LIGHTRED,
|
|
|
|
GREEN,
|
|
|
|
LIGHTGREEN,
|
|
|
|
YELLOW,
|
|
|
|
LIGHTYELLOW,
|
|
|
|
BLUE,
|
|
|
|
LIGHTBLUE,
|
|
|
|
MAGENTA,
|
|
|
|
LIGHTMAGENTA,
|
|
|
|
TEAL,
|
|
|
|
LIGHTTEAL
|
|
|
|
};
|
|
|
|
|
2011-04-19 05:21:57 -05:00
|
|
|
void trace_ln(rust_task *task, uint32_t level, char *message);
|
2010-07-28 01:07:27 -05:00
|
|
|
void trace_ln(uint32_t thread_id, char *prefix, 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;
|
2011-06-28 14:15:41 -05:00
|
|
|
rust_scheduler *_sched;
|
2010-07-19 16:05:18 -05:00
|
|
|
bool _use_labels;
|
|
|
|
bool _use_colors;
|
|
|
|
void trace_ln(rust_task *task, char *message);
|
2010-06-23 23:03:09 -05:00
|
|
|
};
|
|
|
|
|
2011-04-18 09:18:55 -05:00
|
|
|
void update_log_settings(void* crate_map, char* settings);
|
|
|
|
|
2011-04-19 05:21:57 -05:00
|
|
|
extern size_t log_rt_mem;
|
|
|
|
extern size_t log_rt_comm;
|
|
|
|
extern size_t log_rt_task;
|
|
|
|
extern size_t log_rt_dom;
|
|
|
|
extern size_t log_rt_trace;
|
|
|
|
extern size_t log_rt_cache;
|
|
|
|
extern size_t log_rt_upcall;
|
|
|
|
extern size_t log_rt_timer;
|
|
|
|
extern size_t log_rt_gc;
|
|
|
|
extern size_t log_rt_stdlib;
|
|
|
|
extern size_t log_rt_kern;
|
|
|
|
extern size_t log_rt_backtrace;
|
|
|
|
|
2010-07-19 16:05:18 -05:00
|
|
|
#endif /* RUST_LOG_H */
|