about summary refs log tree commit diff
path: root/src/libgreen
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-01-06 10:26:11 -0800
committerAlex Crichton <alex@alexcrichton.com>2014-01-06 13:19:53 -0800
commitac2a24ecc9df66279a7b6df478593b34e1d2449f (patch)
tree06d4a206f68b583c558cc1eaf34b825f3539e6d5 /src/libgreen
parenta6d3e57dca68fde4effdda3e4ae2887aa535fcd6 (diff)
downloadrust-ac2a24ecc9df66279a7b6df478593b34e1d2449f.tar.gz
rust-ac2a24ecc9df66279a7b6df478593b34e1d2449f.zip
Support arbitrary stdout/stderr/logger handles
This will allow capturing of common things like logging messages, stdout prints
(using stdio println), and failure messages (printed to stderr).  Any new prints
added to libstd should be funneled through these task handles to allow capture
as well.

Additionally, this commit redirects logging back through a `Logger` trait so the
log level can be usefully consumed by an arbitrary logger.

This commit also introduces methods to set the task-local stdout handles:

* std::io::stdio::set_stdout
* std::io::stdio::set_stderr
* std::io::logging::set_logger

These methods all return the previous logger just in case it needs to be used
for inspection.

I plan on using this infrastructure for extra::test soon, but we don't quite
have the primitives that I'd like to use for it, so it doesn't migrate
extra::test at this time.

Closes #6369
Diffstat (limited to 'src/libgreen')
-rw-r--r--src/libgreen/task.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/libgreen/task.rs b/src/libgreen/task.rs
index 183fe8d0555..62c9ad12535 100644
--- a/src/libgreen/task.rs
+++ b/src/libgreen/task.rs
@@ -118,13 +118,17 @@ impl GreenTask {
                      f: proc()) -> ~GreenTask {
         let TaskOpts {
             watched: _watched,
-            notify_chan, name, stack_size
+            notify_chan, name, stack_size,
+            stderr, stdout, logger,
         } = opts;
 
         let mut green = GreenTask::new(pool, stack_size, f);
         {
             let task = green.task.get_mut_ref();
             task.name = name;
+            task.logger = logger;
+            task.stderr = stderr;
+            task.stdout = stdout;
             match notify_chan {
                 Some(chan) => {
                     let on_exit = proc(task_result) { chan.send(task_result) };