about summary refs log tree commit diff
path: root/src/libstd/logging.rs
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-01-29 16:33:57 -0800
committerAlex Crichton <alex@alexcrichton.com>2014-02-03 09:32:33 -0800
commitece8a8f520697be50cbe543bebe065c5198dae4d (patch)
treefa1bf049d3b5d781c8c56e0d0491a655ece485a2 /src/libstd/logging.rs
parentbe4fc638092bf896c5c6c0672136b83b71e491ee (diff)
downloadrust-ece8a8f520697be50cbe543bebe065c5198dae4d.tar.gz
rust-ece8a8f520697be50cbe543bebe065c5198dae4d.zip
std: Remove io::io_error
* All I/O now returns IoResult<T> = Result<T, IoError>
* All formatting traits now return fmt::Result = IoResult<()>
* The if_ok!() macro was added to libstd
Diffstat (limited to 'src/libstd/logging.rs')
-rw-r--r--src/libstd/logging.rs11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/libstd/logging.rs b/src/libstd/logging.rs
index 636d3ffd90a..c5e66ffc7be 100644
--- a/src/libstd/logging.rs
+++ b/src/libstd/logging.rs
@@ -102,6 +102,7 @@ use io::Writer;
 use ops::Drop;
 use option::{Some, None, Option};
 use prelude::drop;
+use result::{Ok, Err};
 use rt::local::Local;
 use rt::task::Task;
 use util;
@@ -131,13 +132,19 @@ struct DefaultLogger {
 impl Logger for DefaultLogger {
     // by default, just ignore the level
     fn log(&mut self, _level: u32, args: &fmt::Arguments) {
-        fmt::writeln(&mut self.handle, args);
+        match fmt::writeln(&mut self.handle, args) {
+            Err(e) => fail!("failed to log: {}", e),
+            Ok(()) => {}
+        }
     }
 }
 
 impl Drop for DefaultLogger {
     fn drop(&mut self) {
-        self.handle.flush();
+        match self.handle.flush() {
+            Err(e) => fail!("failed to flush a logger: {}", e),
+            Ok(()) => {}
+        }
     }
 }