Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 23, 2011, 12:45:53 AM (13 years ago)
Author:
landauf
Message:

merged output branch back to trunk.

Changes:

  • you have to include util/Output.h instead of util/Debug.h
  • COUT(x) is now called orxout(level)
  • output levels are now defined by an enum instead of numbers. see util/Output.h for the definition
  • it's possible to use output contexts with orxout(level, context). see util/Output.h for some common contexts. you can define more contexts
  • you must use 'endl' at the end of an output message, '\n' does not flush the message

Output levels:

  • instead of COUT(0) use orxout()
  • instead of COUT(1) use orxout(user_error) or orxout(internal_error)
  • instead of COUT(2) use orxout(user_warning) or orxout(internal_warning)
  • instead of COUT(3) use orxout(user_status/user_info) or orxout(internal_status/internal_info)
  • instead of COUT(4) use orxout(verbose)
  • instead of COUT(5) use orxout(verbose_more)
  • instead of COUT(6) use orxout(verbose_ultra)

Guidelines:

  • user_* levels are for the user, visible in the console and the log-file
  • internal_* levels are for developers, visible in the log-file
  • verbose_* levels are for debugging, only visible if the context of the output is activated

Usage in C++:

  • orxout() << "message" << endl;
  • orxout(level) << "message" << endl;
  • orxout(level, context) << "message" << endl;

Usage in Lua:

  • orxout("message")
  • orxout(orxonox.level.levelname, "message")
  • orxout(orxonox.level.levelname, "context", "message")

Usage in Tcl (and in the in-game-console):

  • orxout levelname message
  • orxout_context levelname context message
  • shortcuts: log message, error message, warning message, status message, info message, debug message
Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/libraries/core/command/IOConsolePOSIX.cc

    r8729 r8858  
    3737#include "util/Clock.h"
    3838#include "util/Math.h"
     39#include "util/output/ConsoleWriter.h"
    3940#include "core/Game.h"
    4041#include "core/input/InputBuffer.h"
     
    5556
    5657    IOConsole::IOConsole()
    57         : shell_(new Shell("IOConsole", false))
     58        : shell_(new Shell("Console", false))
    5859        , buffer_(shell_->getInputBuffer())
    5960        , cout_(std::cout.rdbuf())
     
    7475
    7576        // Disable standard std::cout logging
    76         OutputHandler::getInstance().disableCout();
     77        ConsoleWriter::getInstance().disable();
    7778        // Redirect std::cout to an ostringstream
    7879        // (Other part is in the initialiser list)
     
    8889        std::cout.flush();
    8990        if (!this->origCout_.str().empty())
    90             this->shell_->addOutput(this->origCout_.str(), Shell::None);
     91            this->shell_->addOutput(this->origCout_.str(), Shell::Cout);
    9192        // Erase input and status lines
    9293        this->cout_ << "\033[1G\033[J";
     
    102103        std::cout.rdbuf(this->cout_.rdbuf());
    103104        // Enable standard std::cout logging again
    104         OutputHandler::getInstance().enableCout();
     105        ConsoleWriter::getInstance().enable();
    105106    }
    106107
     
    229230        if (!this->origCout_.str().empty())
    230231        {
    231             this->shell_->addOutput(this->origCout_.str(), Shell::None);
     232            this->shell_->addOutput(this->origCout_.str(), Shell::Cout);
    232233            this->origCout_.str("");
    233234        }
     
    239240        switch (type)
    240241        {
    241         case Shell::Error:   this->cout_ << "\033[91m"; break;
    242         case Shell::Warning: this->cout_ << "\033[93m"; break;
    243         case Shell::Info:    this->cout_ << "\033[90m"; break;
    244         case Shell::Debug:   this->cout_ << "\033[90m"; break;
    245         case Shell::Verbose: this->cout_ << "\033[90m"; break;
    246         case Shell::Ultra:   this->cout_ << "\033[90m"; break;
    247         case Shell::Command: this->cout_ << "\033[36m"; break;
    248         case Shell::Hint:    this->cout_ << "\033[33m"; break;
    249         case Shell::TDebug:  this->cout_ << "\033[95m"; break;
    250         default: break;
     242            case Shell::Message:
     243            case Shell::DebugOutput:     this->cout_ << "\033[0m"; break;
     244
     245            case Shell::UserError:       this->cout_ << "\033[91m"; break;
     246            case Shell::UserWarning:     this->cout_ << "\033[93m"; break;
     247            case Shell::UserStatus:      this->cout_ << "\033[92m"; break;
     248            case Shell::UserInfo:        this->cout_ << "\033[96m"; break;
     249
     250            case Shell::InternalError:   this->cout_ << "\033[31m"; break;
     251            case Shell::InternalWarning: this->cout_ << "\033[33m"; break;
     252            case Shell::InternalStatus:  this->cout_ << "\033[32m"; break;
     253            case Shell::InternalInfo:    this->cout_ << "\033[36m"; break;
     254
     255            case Shell::Verbose:         this->cout_ << "\033[94m"; break;
     256            case Shell::VerboseMore:     this->cout_ << "\033[34m"; break;
     257            case Shell::VerboseUltra:    this->cout_ << "\033[34m"; break;
     258
     259            case Shell::Command:         this->cout_ << "\033[95m"; break;
     260            case Shell::Hint:            this->cout_ << "\033[35m"; break;
     261
     262            default:                     this->cout_ << "\033[37m"; break;
    251263        }
    252264
     
    371383    void IOConsole::executed()
    372384    {
    373         this->shell_->addOutput(this->promptString_ + this->shell_->getInput() + '\n', Shell::Command);
     385        this->shell_->addOutput(this->promptString_ + this->shell_->getInput(), Shell::Command);
    374386    }
    375387
     
    378390    {
    379391        // Exit is not an option, just do nothing (Shell doesn't really exit too)
    380     }
    381 
    382     //! Called if only the last output-line has changed
    383     void IOConsole::onlyLastLineChanged()
    384     {
    385         // Save cursor position and move it to the beginning of the first output line
    386         this->cout_ << "\033[s\033[1A\033[1G";
    387         // Erase the line
    388         this->cout_ << "\033[K";
    389         // Reprint the last output line
    390         this->printOutputLine(this->shell_->getNewestLineIterator()->first, this->shell_->getNewestLineIterator()->second);
    391         // Restore cursor
    392         this->cout_ << "\033[u";
    393         this->cout_.flush();
    394392    }
    395393
Note: See TracChangeset for help on using the changeset viewer.