Skip to content

Commit b0c2416

Browse files
committed
Clean up logging output. Closes #1088
1 parent 369fc5e commit b0c2416

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

src/rt/rust_log.cpp

+14-8
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
* Synchronizes access to the underlying logging mechanism.
1414
*/
1515
static lock_and_signal _log_lock;
16-
static uint32_t _last_thread_id;
1716

1817
rust_log::rust_log(rust_srv *srv, rust_scheduler *sched) :
1918
_srv(srv),
@@ -67,26 +66,29 @@ append_string(char *buffer, const char *format, ...) {
6766
}
6867

6968
void
70-
rust_log::trace_ln(uint32_t thread_id, char *prefix, char *message) {
69+
rust_log::trace_ln(char *prefix, char *message) {
7170
char buffer[BUF_BYTES] = "";
7271
_log_lock.lock();
73-
append_string(buffer, "%-34s", prefix);
72+
append_string(buffer, "%s", prefix);
7473
append_string(buffer, "%s", message);
75-
if (_last_thread_id != thread_id) {
76-
_last_thread_id = thread_id;
77-
_srv->log("---");
78-
}
7974
_srv->log(buffer);
8075
_log_lock.unlock();
8176
}
8277

8378
void
8479
rust_log::trace_ln(rust_task *task, uint32_t level, char *message) {
80+
81+
82+
// FIXME: The scheduler and task names used to have meaning,
83+
// but they are always equal to 'main' currently
84+
#if 0
85+
8586
#if defined(__WIN32__)
8687
uint32_t thread_id = 0;
8788
#else
8889
uint32_t thread_id = hash((uintptr_t) pthread_self());
8990
#endif
91+
9092
char prefix[BUF_BYTES] = "";
9193
if (_sched && _sched->name) {
9294
append_string(prefix, "%04" PRIxPTR ":%.10s:",
@@ -102,7 +104,11 @@ rust_log::trace_ln(rust_task *task, uint32_t level, char *message) {
102104
append_string(prefix, "0x%08" PRIxPTR ":", (uintptr_t) task);
103105
}
104106
}
105-
trace_ln(thread_id, prefix, message);
107+
#else
108+
char prefix[BUF_BYTES] = "";
109+
#endif
110+
111+
trace_ln(prefix, message);
106112
}
107113

108114
// Reading log directives and setting log level vars

src/rt/rust_log.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class rust_log {
4242
virtual ~rust_log();
4343

4444
void trace_ln(rust_task *task, uint32_t level, char *message);
45-
void trace_ln(uint32_t thread_id, char *prefix, char *message);
45+
void trace_ln(char *prefix, char *message);
4646
bool is_tracing(uint32_t type_bits);
4747

4848
private:

src/rt/rust_srv.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ rust_srv::realloc(void *p, size_t bytes) {
2525

2626
void
2727
rust_srv::log(char const *msg) {
28-
printf("rt: %s\n", msg);
28+
printf("rust: %s\n", msg);
2929
// FIXME: flushing each time is expensive, but at the moment
3030
// necessary to get output through before a rust_task::fail
3131
// call. This should be changed.

0 commit comments

Comments
 (0)