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/Shell.h

    r8729 r8858  
    4848#include <vector>
    4949
    50 #include "util/OutputHandler.h"
     50#include "util/output/BaseWriter.h"
    5151#include "core/Core.h"
    5252#include "core/OrxonoxClass.h"
     
    6666        private:
    6767            virtual void linesChanged() {}          ///< Called if all output-lines have changed
    68             virtual void onlyLastLineChanged() {}   ///< Called if only the last output-line has changed
    6968            virtual void lineAdded() {}             ///< Called if a new line was added to the output
    7069            virtual void inputChanged() {}          ///< Called if the input has changed
     
    7877        @brief The Shell is the logical component of the console that displays output to the user and allows him to enter commands.
    7978
    80         The Shell gathers output sent from OutputHandler by inheriting from OutputListener.
     79        The Shell gathers output sent from OutputManager by inheriting from BaseWriter.
    8180        The output-lines are stored in the shell, so they can be displayed in a graphical
    8281        console. Additionally the Shell has an InputBuffer which is needed by the user to
     
    8584        Different graphical consoles build upon a Shell, for example InGameConsole and IOConsole.
    8685    */
    87     class _CoreExport Shell : public OutputListener, public DevModeListener
     86    class _CoreExport Shell : public BaseWriter, public DevModeListener
    8887    {
    8988        public:
     
    9190            enum LineType
    9291            {
    93                 TDebug  = OutputLevel::TDebug,
    94                 None    = OutputLevel::None,
    95                 Warning = OutputLevel::Warning,
    96                 Error   = OutputLevel::Error,
    97                 Info    = OutputLevel::Info,
    98                 Debug   = OutputLevel::Debug,
    99                 Verbose = OutputLevel::Verbose,
    100                 Ultra   = OutputLevel::Ultra,
     92                DebugOutput     = debug_output,
     93                Message         = message,
     94                UserError       = user_error,
     95                UserWarning     = user_warning,
     96                UserStatus      = user_status,
     97                UserInfo        = user_info,
     98                InternalError   = internal_error,
     99                InternalWarning = internal_warning,
     100                InternalStatus  = internal_status,
     101                InternalInfo    = internal_info,
     102                Verbose         = verbose,
     103                VerboseMore     = verbose_more,
     104                VerboseUltra    = verbose_ultra,
     105                Cout,
    101106                Input,
    102107                Command,
     108                Result,
    103109                Hint
    104110            };
     
    127133            LineList::const_iterator getEndIterator() const;
    128134
    129             void addOutput(const std::string& text, LineType type = None);
     135            void addOutput(const std::string& text, LineType type = DebugOutput);
     136            void addLine(const std::string& line, LineType type = DebugOutput);
    130137            void clearOutput();
    131138
     
    150157            const std::string& getFromHistory() const;
    151158            void clearInput();
    152             // OutputListener
    153             void outputChanged(int level);
     159            // BaseWriter
     160            virtual void printLine(const std::string& line, OutputLevel level);
    154161
    155162            void configureInputBuffer();
     
    183190            std::list<ShellListener*> listeners_;           ///< The registered shell listeners
    184191            InputBuffer*              inputBuffer_;         ///< The input buffer that is needed by the user to enter text
    185             std::stringstream         outputBuffer_;        ///< The output buffer that is used to retrieve lines of output from OutputListener
    186             bool                      bFinishedLastLine_;   ///< Stores if the most recent output-line was terminated with a line-break or if more output is expected for this line
    187192            LineList                  outputLines_;         ///< A list of all output-lines that were displayed in the shell so far
    188193            LineList::const_iterator  scrollIterator_;      ///< An iterator to an entry of the list of output-lines, changes if the user scrolls through the output in the shell
    189194            unsigned int              scrollPosition_;      ///< The number of the line that is currently being referenced by scrollIterator_
    190195            unsigned int              historyPosition_;     ///< If the user scrolls through the history of entered commands (stored in commandHistory_), this contains the currently viewed history entry
    191 
    192             const std::string         consoleName_;         ///< The name of this shell - used to define the name of the soft-debug-level config-value
    193196            const bool                bScrollable_;         ///< If true, the user can scroll through the output-lines
    194197
     
    197200            unsigned int              historyOffset_;       ///< The command history is a circular buffer, this variable defines the current write-offset
    198201            std::vector<std::string>  commandHistory_;      ///< The history of commands that were entered by the user
    199             int                       debugLevel_;          //!< The maximum level of output that is displayed in the shell (will be passed to OutputListener to filter output)
    200202            static unsigned int       cacheSize_s;          ///< The maximum cache size of the CommandExecutor - this is stored here for better readability of the config file and because CommandExecutor is no OrxonoxClass
    201203    };
Note: See TracChangeset for help on using the changeset viewer.