Index: code/branches/console/src/libraries/core/IOConsole.cc
===================================================================
--- code/branches/console/src/libraries/core/IOConsole.cc	(revision 6034)
+++ code/branches/console/src/libraries/core/IOConsole.cc	(revision 6037)
@@ -74,5 +74,5 @@
     {
         // Method only gets called upon start to draw all the lines
-        // or when scrolling. But scrolling is disable and the output
+        // or when scrolling. But scrolling is disabled and the output
         // is already in std::cout when we start the IOConsole
     }
@@ -82,5 +82,5 @@
     {
         this->printInputLine();
-        std::cout.flush();
+        this->cout_.flush();
     }
 
@@ -89,5 +89,5 @@
     {
         this->printInputLine();
-        std::cout.flush();
+        this->cout_.flush();
     }
 
@@ -112,5 +112,4 @@
 #include <termios.h>
 #include <sys/ioctl.h>
-#include <sys/stat.h>
 
 namespace orxonox
@@ -129,7 +128,8 @@
         : shell_(new Shell("IOConsole", false, true))
         , buffer_(shell_->getInputBuffer())
-        , originalTerminalSettings_(new termios())
+        , cout_(std::cout.rdbuf())
         , bStatusPrinted_(false)
         , promptString_("orxonox # ")
+        , originalTerminalSettings_(new termios())
     {
         this->setTerminalMode();
@@ -146,12 +146,20 @@
         // Disable standard std::cout logging
         OutputHandler::getInstance().disableCout();
+        // Redirect std::cout to an ostringstream
+        // (Other part is in the initialiser list)
+        std::cout.rdbuf(this->origCout_.rdbuf());
+
+        // Make sure we make way for the status lines
+        this->update(Game::getInstance().getGameClock());
     }
 
     IOConsole::~IOConsole()
     {
+        // Empty all buffers
+        this->update(Game::getInstance().getGameClock());
         // Goto last line and create a new one
         if (this->bStatusPrinted_)
-            std::cout << "\033[" << this->statusLineWidths_.size() << 'E';
-        std::cout << std::endl;
+            this->cout_ << "\033[" << this->statusLineWidths_.size() << 'E';
+        this->cout_ << std::endl;
 
         resetTerminalMode();
@@ -159,4 +167,6 @@
         this->shell_->destroy();
 
+        // Restore this->cout_ redirection
+        std::cout.rdbuf(this->cout_.rdbuf());
         // Enable standard std::cout logging again
         OutputHandler::getInstance().enableCout();
@@ -250,4 +260,11 @@
             this->buffer_->buttonPressed(KeyEvent(KeyCode::Escape, '\033', 0));
 
+        // Process output written to std::cout
+        if (!this->origCout_.str().empty())
+        {
+            this->shell_->addOutputLine(this->origCout_.str());
+            this->origCout_.str("");
+        }
+
         // Determine terminal width and height
         this->lastTerminalWidth_ = this->terminalWidth_;
@@ -261,7 +278,7 @@
             // but that line might very well be the last
             int newLines = std::min((int)this->statusLineWidths_.size(), -heightDiff);
-            std::cout << std::string(newLines, '\n');
+            this->cout_ << std::string(newLines, '\n');
             // Move cursor up again
-            std::cout << "\033[" << newLines << 'F';
+            this->cout_ << "\033[" << newLines << 'F';
         }
 
@@ -269,14 +286,14 @@
         {
             // Print new lines to make way for status lines
-            std::cout << std::string(this->statusLineWidths_.size(), '\n');
+            this->cout_ << std::string(this->statusLineWidths_.size(), '\n');
             // Move cursor up again
-            std::cout << "\033[" << this->statusLineWidths_.size() << 'F';
+            this->cout_ << "\033[" << this->statusLineWidths_.size() << 'F';
             this->bStatusPrinted_ = true;
         }
         // Erase status and input lines
-        std::cout << "\033[1G\033[J";
+        this->cout_ << "\033[1G\033[J";
         this->printInputLine();
         this->printStatusLines();
-        std::cout.flush();
+        this->cout_.flush();
     }
 
@@ -284,17 +301,17 @@
     {
         std::string output = text;
+/*
         int level = this->extractLogLevel(&output);
 
         // Colour line
-/*
         switch (level)
         {
-        case -1: std::cout << "\033[37m"; break;
-        case  1: std::cout << "\033[91m"; break;
-        case  2: std::cout << "\033[31m"; break;
-        case  3: std::cout << "\033[34m"; break;
-        case  4: std::cout << "\033[36m"; break;
-        case  5: std::cout << "\033[35m"; break;
-        case  6: std::cout << "\033[37m"; break;
+        case -1: this->cout_ << "\033[37m"; break;
+        case  1: this->cout_ << "\033[91m"; break;
+        case  2: this->cout_ << "\033[31m"; break;
+        case  3: this->cout_ << "\033[34m"; break;
+        case  4: this->cout_ << "\033[36m"; break;
+        case  5: this->cout_ << "\033[35m"; break;
+        case  6: this->cout_ << "\033[37m"; break;
         default: break;
         }
@@ -302,8 +319,8 @@
 
         // Print output line
-        std::cout << output;
+        this->cout_ << output;
 
         // Reset colour to white
-//        std::cout << "\033[37m";
+//        this->cout_ << "\033[37m";
     }
 
@@ -311,15 +328,15 @@
     {
         // Set cursor to the beginning of the line and erase the line
-        std::cout << "\033[1G\033[K";
+        this->cout_ << "\033[1G\033[K";
         // Indicate a command prompt
-        std::cout << this->promptString_;
+        this->cout_ << this->promptString_;
         // Save cursor position
-        std::cout << "\033[s";
+        this->cout_ << "\033[s";
         // Print command line buffer
-        std::cout << this->shell_->getInput();
+        this->cout_ << this->shell_->getInput();
         // Restore cursor position and move it to the right
-        std::cout << "\033[u";
+        this->cout_ << "\033[u";
         if (this->buffer_->getCursorPosition() > 0)
-            std::cout << "\033[" << this->buffer_->getCursorPosition() << "C";
+            this->cout_ << "\033[" << this->buffer_->getCursorPosition() << "C";
     }
 
@@ -329,11 +346,12 @@
         {
             // Save cursor position
-            std::cout << "\033[s";
+            this->cout_ << "\033[s";
             // Move cursor down (don't create a new line here because the buffer might flush then!)
-            std::cout << "\033[1E";
-            std::cout << std::fixed << std::setprecision(2) << std::setw(5) << Game::getInstance().getAvgFPS() << " fps, ";
-            std::cout <<               std::setprecision(2) << std::setw(5) << Game::getInstance().getAvgTickTime() << " ms tick time";
+            this->cout_ << "\033[1E";
+            //this->cout_ << std::fixed << std::setprecision(2) << std::setw(5) << Game::getInstance().getAvgFPS() << " fps, ";
+            //this->cout_ <<               std::setprecision(2) << std::setw(5) << Game::getInstance().getAvgTickTime() << " ms tick time";
+            this->cout_ << "Terminal width: " << this->terminalWidth_ << ", height: " << this->terminalHeight_;
             // Restore cursor position
-            std::cout << "\033[u";
+            this->cout_ << "\033[u";
             this->bStatusPrinted_ = true;
         }
@@ -397,12 +415,12 @@
     {
         // Save cursor position and move it to the beginning of the first output line
-        std::cout << "\033[s\033[1F";
+        this->cout_ << "\033[s\033[1F";
         // Erase the line
-        std::cout << "\033[K";
+        this->cout_ << "\033[K";
         // Reprint the last output line
         this->printLogText(*(this->shell_->getNewestLineIterator()));
         // Restore cursor
-        std::cout << "\033[u";
-        std::cout.flush();
+        this->cout_ << "\033[u";
+        this->cout_.flush();
     }
 
@@ -412,21 +430,21 @@
         // Move cursor to the bottom line
         if (this->bStatusPrinted_)
-            std::cout << "\033[" << this->statusLineWidths_.size() << 'E';
+            this->cout_ << "\033[" << this->statusLineWidths_.size() << 'E';
         // Create new lines on the screen
         int newLines = this->shell_->getNewestLineIterator()->size() / this->terminalWidth_ + 1;
-        std::cout << std::string(newLines, '\n');
+        this->cout_ << std::string(newLines, '\n');
         // Move cursor to the beginning of the new (last) output line
-        std::cout << "\033[" << (newLines + this->statusLineWidths_.size()) << 'F';
+        this->cout_ << "\033[" << (newLines + this->statusLineWidths_.size()) << 'F';
         // Erase screen from here
-        std::cout << "\033[J";
+        this->cout_ << "\033[J";
         // Print the new output line
         for (int i = 0; i < newLines; ++i)
             this->printLogText(this->shell_->getNewestLineIterator()->substr(i*this->terminalWidth_, this->terminalWidth_));
         // Move cursor down
-        std::cout << "\033[1E";
+        this->cout_ << "\033[1E";
         // Print status and input lines
         this->printInputLine();
         this->printStatusLines();
-        std::cout.flush();
+        this->cout_.flush();
     }
 }
@@ -457,5 +475,5 @@
         this->lastTerminalHeight_ = this->terminalHeight_;
 
-        // Disable standard std::cout logging
+        // Disable standard this->cout_ logging
         OutputHandler::getInstance().disableCout();
 */
@@ -468,5 +486,5 @@
         this->shell_->destroy();
 
-        // Enable standard std::cout logging again
+        // Enable standard this->cout_ logging again
         OutputHandler::getInstance().enableCout();
 */
Index: code/branches/console/src/libraries/core/IOConsole.h
===================================================================
--- code/branches/console/src/libraries/core/IOConsole.h	(revision 6034)
+++ code/branches/console/src/libraries/core/IOConsole.h	(revision 6037)
@@ -33,4 +33,5 @@
 #include "CorePrereqs.h"
 
+#include <sstream>
 #include <string>
 #include <vector>
@@ -75,4 +76,6 @@
         Shell*                  shell_;
         InputBuffer*            buffer_;
+        std::ostream            cout_;
+        std::ostringstream      origCout_;
         unsigned int            terminalWidth_;
         unsigned int            terminalHeight_;
