aboutsummaryrefslogtreecommitdiff
path: root/src/rt/rust_log.cpp
diff options
context:
space:
mode:
authorMichael Bebenita <[email protected]>2010-07-27 23:07:27 -0700
committerGraydon Hoare <[email protected]>2010-07-28 20:30:28 -0700
commit712249d6b8f3c4f08514c5917effcbced0f0477a (patch)
tree2103bd1fd26a8e0c39b9b899a1d4456803919c17 /src/rt/rust_log.cpp
parentarray_list improvements. (diff)
downloadrust-712249d6b8f3c4f08514c5917effcbced0f0477a.tar.xz
rust-712249d6b8f3c4f08514c5917effcbced0f0477a.zip
Log a separator when logging switches between threads.
Diffstat (limited to 'src/rt/rust_log.cpp')
-rw-r--r--src/rt/rust_log.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/rt/rust_log.cpp b/src/rt/rust_log.cpp
index cd362cc8..48fcd0f1 100644
--- a/src/rt/rust_log.cpp
+++ b/src/rt/rust_log.cpp
@@ -61,6 +61,7 @@ static const char * _foreground_colors[] = { "[37m",
* Synchronizes access to the underlying logging mechanism.
*/
static spin_lock _log_lock;
+static uint32_t _last_thread_id;
rust_log::rust_log(rust_srv *srv, rust_dom *dom) :
_srv(srv),
@@ -122,7 +123,7 @@ append_string(char *buffer, rust_log::ansi_color color,
}
void
-rust_log::trace_ln(char *prefix, char *message) {
+rust_log::trace_ln(uint32_t thread_id, char *prefix, char *message) {
char buffer[1024] = "";
_log_lock.lock();
append_string(buffer, "%-34s", prefix);
@@ -130,6 +131,10 @@ rust_log::trace_ln(char *prefix, char *message) {
append_string(buffer, " ");
}
append_string(buffer, "%s", message);
+ if (_last_thread_id != thread_id) {
+ _last_thread_id = thread_id;
+ _srv->log("---");
+ }
_srv->log(buffer);
_log_lock.unlock();
}
@@ -147,7 +152,7 @@ rust_log::trace_ln(rust_task *task, char *message) {
if (task) {
append_string(prefix, "0x%08" PRIxPTR ":", (uintptr_t) task);
}
- trace_ln(prefix, message);
+ trace_ln(thread_id, prefix, message);
}
/**