Skip to content

Commit 5930463

Browse files
committed
Tidy up some drift in runtime logging, close #1380.
1 parent 7fd62bb commit 5930463

File tree

4 files changed

+23
-15
lines changed

4 files changed

+23
-15
lines changed

Diff for: src/rt/rust_log.h

+7-5
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,20 @@
33
#define RUST_LOG_H
44

55
const uint32_t log_err = 0;
6-
const uint32_t log_note = 1;
6+
const uint32_t log_warn = 1;
7+
const uint32_t log_info = 2;
8+
const uint32_t log_debug = 3;
79

810
#define LOG(task, field, ...) \
9-
DLOG_LVL(log_note, task, task->sched, field, __VA_ARGS__)
11+
DLOG_LVL(log_debug, task, task->sched, field, __VA_ARGS__)
1012
#define LOG_ERR(task, field, ...) \
1113
DLOG_LVL(log_err, task, task->sched, field, __VA_ARGS__)
1214
#define DLOG(sched, field, ...) \
13-
DLOG_LVL(log_note, NULL, sched, field, __VA_ARGS__)
15+
DLOG_LVL(log_debug, NULL, sched, field, __VA_ARGS__)
1416
#define DLOG_ERR(sched, field, ...) \
1517
DLOG_LVL(log_err, NULL, sched, field, __VA_ARGS__)
1618
#define LOGPTR(sched, msg, ptrval) \
17-
DLOG_LVL(log_note, NULL, sched, mem, "%s 0x%" PRIxPTR, msg, ptrval)
19+
DLOG_LVL(log_debug, NULL, sched, mem, "%s 0x%" PRIxPTR, msg, ptrval)
1820
#define DLOG_LVL(lvl, task, sched, field, ...) \
1921
do { \
2022
rust_scheduler* _d_ = sched; \
@@ -24,7 +26,7 @@ const uint32_t log_note = 1;
2426
} while (0)
2527

2628
#define KLOG(k, field, ...) \
27-
KLOG_LVL(k, field, log_note, __VA_ARGS__)
29+
KLOG_LVL(k, field, log_debug, __VA_ARGS__)
2830
#define KLOG_LVL(k, field, lvl, ...) \
2931
do { \
3032
if (log_rt_##field >= lvl) { \

Diff for: src/rt/rust_scheduler.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ rust_scheduler::rust_scheduler(rust_kernel *kernel,
1919
ref_count(1),
2020
interrupt_flag(0),
2121
_log(srv, this),
22-
log_lvl(log_note),
22+
log_lvl(log_debug),
2323
srv(srv),
2424
// TODO: calculate a per scheduler name.
2525
name("main"),
@@ -203,12 +203,12 @@ rust_scheduler::schedule_task(int id) {
203203

204204
void
205205
rust_scheduler::log_state() {
206-
if (log_rt_task < log_note) return;
206+
if (log_rt_task < log_debug) return;
207207

208208
if (!running_tasks.is_empty()) {
209-
log(NULL, log_note, "running tasks:");
209+
log(NULL, log_debug, "running tasks:");
210210
for (size_t i = 0; i < running_tasks.length(); i++) {
211-
log(NULL, log_note, "\t task: %s @0x%" PRIxPTR
211+
log(NULL, log_debug, "\t task: %s @0x%" PRIxPTR
212212
" remaining: %" PRId64 " us",
213213
running_tasks[i]->name,
214214
running_tasks[i],
@@ -217,19 +217,19 @@ rust_scheduler::log_state() {
217217
}
218218

219219
if (!blocked_tasks.is_empty()) {
220-
log(NULL, log_note, "blocked tasks:");
220+
log(NULL, log_debug, "blocked tasks:");
221221
for (size_t i = 0; i < blocked_tasks.length(); i++) {
222-
log(NULL, log_note, "\t task: %s @0x%" PRIxPTR ", blocked on: 0x%"
222+
log(NULL, log_debug, "\t task: %s @0x%" PRIxPTR ", blocked on: 0x%"
223223
PRIxPTR " '%s'",
224224
blocked_tasks[i]->name, blocked_tasks[i],
225225
blocked_tasks[i]->cond, blocked_tasks[i]->cond_name);
226226
}
227227
}
228228

229229
if (!dead_tasks.is_empty()) {
230-
log(NULL, log_note, "dead tasks:");
230+
log(NULL, log_debug, "dead tasks:");
231231
for (size_t i = 0; i < dead_tasks.length(); i++) {
232-
log(NULL, log_note, "\t task: %s 0x%" PRIxPTR,
232+
log(NULL, log_debug, "\t task: %s 0x%" PRIxPTR,
233233
dead_tasks[i]->name, dead_tasks[i]);
234234
}
235235
}

Diff for: src/rt/rust_scheduler.h

+8
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,15 @@ struct rust_scheduler : public kernel_owned<rust_scheduler>,
4343

4444
// Fields known only by the runtime:
4545
rust_log _log;
46+
47+
// NB: this is used to filter *runtime-originating* debug
48+
// logging, on a per-scheduler basis. It's not likely what
49+
// you want to expose to the user in terms of per-task
50+
// or per-module logging control. By default all schedulers
51+
// are set to debug-level logging here, and filtered by
52+
// runtime category using the pseudo-modules ::rt::foo.
4653
uint32_t log_lvl;
54+
4755
rust_srv *srv;
4856
const char *const name;
4957

Diff for: src/rt/rust_shape.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -555,8 +555,6 @@ shape_cmp_type(int8_t *result, const type_desc *tydesc,
555555
extern "C" void
556556
shape_log_type(const type_desc *tydesc, uint8_t *data, uint32_t level) {
557557
rust_task *task = rust_scheduler::get_task();
558-
if (task->sched->log_lvl < level)
559-
return; // TODO: Don't evaluate at all?
560558

561559
shape::arena arena;
562560
shape::type_param *params =

0 commit comments

Comments
 (0)