Tidy up some drift in runtime logging, close #1380.

This commit is contained in:
Graydon Hoare 2011-12-28 11:53:12 -08:00
parent 7fd62bb2b5
commit 5930463faa
4 changed files with 23 additions and 15 deletions

View file

@ -3,18 +3,20 @@
#define RUST_LOG_H
const uint32_t log_err = 0;
const uint32_t log_note = 1;
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_note, task, task->sched, field, __VA_ARGS__)
DLOG_LVL(log_debug, task, task->sched, field, __VA_ARGS__)
#define LOG_ERR(task, field, ...) \
DLOG_LVL(log_err, task, task->sched, field, __VA_ARGS__)
#define DLOG(sched, field, ...) \
DLOG_LVL(log_note, NULL, sched, field, __VA_ARGS__)
DLOG_LVL(log_debug, 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)
DLOG_LVL(log_debug, NULL, sched, mem, "%s 0x%" PRIxPTR, msg, ptrval)
#define DLOG_LVL(lvl, task, sched, field, ...) \
do { \
rust_scheduler* _d_ = sched; \
@ -24,7 +26,7 @@ const uint32_t log_note = 1;
} while (0)
#define KLOG(k, field, ...) \
KLOG_LVL(k, field, log_note, __VA_ARGS__)
KLOG_LVL(k, field, log_debug, __VA_ARGS__)
#define KLOG_LVL(k, field, lvl, ...) \
do { \
if (log_rt_##field >= lvl) { \

View file

@ -19,7 +19,7 @@ rust_scheduler::rust_scheduler(rust_kernel *kernel,
ref_count(1),
interrupt_flag(0),
_log(srv, this),
log_lvl(log_note),
log_lvl(log_debug),
srv(srv),
// TODO: calculate a per scheduler name.
name("main"),
@ -203,12 +203,12 @@ rust_scheduler::schedule_task(int id) {
void
rust_scheduler::log_state() {
if (log_rt_task < log_note) return;
if (log_rt_task < log_debug) return;
if (!running_tasks.is_empty()) {
log(NULL, log_note, "running tasks:");
log(NULL, log_debug, "running tasks:");
for (size_t i = 0; i < running_tasks.length(); i++) {
log(NULL, log_note, "\t task: %s @0x%" PRIxPTR
log(NULL, log_debug, "\t task: %s @0x%" PRIxPTR
" remaining: %" PRId64 " us",
running_tasks[i]->name,
running_tasks[i],
@ -217,9 +217,9 @@ rust_scheduler::log_state() {
}
if (!blocked_tasks.is_empty()) {
log(NULL, log_note, "blocked tasks:");
log(NULL, log_debug, "blocked tasks:");
for (size_t i = 0; i < blocked_tasks.length(); i++) {
log(NULL, log_note, "\t task: %s @0x%" PRIxPTR ", blocked on: 0x%"
log(NULL, log_debug, "\t task: %s @0x%" PRIxPTR ", blocked on: 0x%"
PRIxPTR " '%s'",
blocked_tasks[i]->name, blocked_tasks[i],
blocked_tasks[i]->cond, blocked_tasks[i]->cond_name);
@ -227,9 +227,9 @@ rust_scheduler::log_state() {
}
if (!dead_tasks.is_empty()) {
log(NULL, log_note, "dead tasks:");
log(NULL, log_debug, "dead tasks:");
for (size_t i = 0; i < dead_tasks.length(); i++) {
log(NULL, log_note, "\t task: %s 0x%" PRIxPTR,
log(NULL, log_debug, "\t task: %s 0x%" PRIxPTR,
dead_tasks[i]->name, dead_tasks[i]);
}
}

View file

@ -43,7 +43,15 @@ struct rust_scheduler : public kernel_owned<rust_scheduler>,
// Fields known only by the runtime:
rust_log _log;
// NB: this is used to filter *runtime-originating* debug
// logging, on a per-scheduler basis. It's not likely what
// you want to expose to the user in terms of per-task
// or per-module logging control. By default all schedulers
// are set to debug-level logging here, and filtered by
// runtime category using the pseudo-modules ::rt::foo.
uint32_t log_lvl;
rust_srv *srv;
const char *const name;

View file

@ -555,8 +555,6 @@ shape_cmp_type(int8_t *result, const type_desc *tydesc,
extern "C" void
shape_log_type(const type_desc *tydesc, uint8_t *data, uint32_t level) {
rust_task *task = rust_scheduler::get_task();
if (task->sched->log_lvl < level)
return; // TODO: Don't evaluate at all?
shape::arena arena;
shape::type_param *params =