rust/src/rt/rust_log.h

74 lines
2.6 KiB
C
Raw Normal View History

// -*- c++ -*-
#ifndef RUST_LOG_H
#define RUST_LOG_H
2010-06-23 21:03:09 -07:00
const uint32_t log_err = 0;
const uint32_t log_warn = 1;
const uint32_t log_info = 2;
const uint32_t log_debug = 3;
#define LOG(task, field, ...) \
DLOG_LVL(log_debug, task, task->sched_loop, field, __VA_ARGS__)
#define LOG_ERR(task, field, ...) \
DLOG_LVL(log_err, task, task->sched_loop, field, __VA_ARGS__)
#define DLOG(sched_loop, field, ...) \
DLOG_LVL(log_debug, NULL, sched_loop, field, __VA_ARGS__)
#define DLOG_ERR(sched_loop, field, ...) \
DLOG_LVL(log_err, NULL, sched_loop, field, __VA_ARGS__)
#define LOGPTR(sched_loop, msg, ptrval) \
DLOG_LVL(log_debug, NULL, sched_loop, mem, "%s 0x%" PRIxPTR, msg, ptrval)
#define DLOG_LVL(lvl, task, sched_loop, field, ...) \
do { \
rust_sched_loop* _d_ = sched_loop; \
if (log_rt_##field >= lvl && _d_->log_lvl >= lvl) { \
_d_->log(task, lvl, __VA_ARGS__); \
} \
} while (0)
#define KLOG(k, field, ...) \
KLOG_LVL(k, field, log_debug, __VA_ARGS__)
#define KLOG_LVL(k, field, lvl, ...) \
do { \
if (log_rt_##field >= lvl) { \
(k)->log(lvl, __VA_ARGS__); \
} \
} while (0)
struct rust_sched_loop;
struct rust_task;
2010-06-23 21:03:09 -07:00
class rust_log {
2010-06-23 21:03:09 -07:00
public:
2012-04-01 22:18:40 -05:00
rust_log(rust_env *env, rust_sched_loop *sched_loop);
2010-06-23 21:03:09 -07:00
virtual ~rust_log();
void trace_ln(rust_task *task, uint32_t level, char *message);
2011-11-07 14:14:36 -08:00
void trace_ln(char *prefix, char *message);
2010-06-23 21:03:09 -07:00
bool is_tracing(uint32_t type_bits);
private:
2012-04-01 22:18:40 -05:00
rust_env *_env;
rust_sched_loop *_sched_loop;
bool _use_labels;
void trace_ln(rust_task *task, char *message);
2010-06-23 21:03:09 -07:00
};
void update_log_settings(void* crate_map, char* settings);
extern uint32_t log_rt_mem;
extern uint32_t log_rt_comm;
extern uint32_t log_rt_task;
extern uint32_t log_rt_dom;
extern uint32_t log_rt_trace;
extern uint32_t log_rt_cache;
extern uint32_t log_rt_upcall;
extern uint32_t log_rt_timer;
extern uint32_t log_rt_gc;
extern uint32_t log_rt_stdlib;
extern uint32_t log_rt_kern;
extern uint32_t log_rt_backtrace;
extern uint32_t log_rt_callback;
#endif /* RUST_LOG_H */