Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 2, 2009, 5:54:13 PM (15 years ago)
Author:
rgrieder
Message:

IOConsole cleanup and added ConsoleWriter to the OutputHandler so that we get std::cout output before the creation of the IOConsole.

Location:
code/branches/console/src/libraries/util
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/console/src/libraries/util/OutputHandler.cc

    r6007 r6015  
    118118        std::ofstream logFile_;     //! File handle for the log file
    119119        std::string   logFilename_; //! Filename of the log file
     120    };
     121
     122
     123    /////////////////////////
     124    ///// ConsoleWriter /////
     125    /////////////////////////
     126    /**
     127    @brief
     128        Writes the output to std::cout.
     129    @note
     130        This listener will usually be disable once an actual shell with console is instantiated.
     131    */
     132    class ConsoleWriter : public OutputListener
     133    {
     134    public:
     135        //! Only assigns the output stream with std::cout
     136        ConsoleWriter()
     137            : OutputListener("consoleLog")
     138        {
     139            this->outputStream_ = &std::cout;
     140        }
    120141    };
    121142
     
    176197        : outputLevel_(OutputLevel::Verbose)
    177198    {
     199#ifdef ORXONOX_RELEASE
     200        const OutputLevel::Value defaultLevelConsole = OutputLevel::Error;
     201        const OutputLevel::Value defaultLevelLogFile = OutputLevel::Info;
     202#else
     203        const OutputLevel::Value defaultLevelConsole = OutputLevel::Info;
     204        const OutputLevel::Value defaultLevelLogFile = OutputLevel::Debug;
     205#endif
     206
    178207        this->logFile_ = new LogFileWriter();
    179208        // Use default level until we get the configValue from the Core
    180         this->logFile_->softDebugLevel_ = OutputLevel::Debug;
     209        this->logFile_->softDebugLevel_ = defaultLevelLogFile;
    181210        this->registerOutputListener(this->logFile_);
     211
     212        this->consoleWriter_ = new ConsoleWriter();
     213        this->consoleWriter_->softDebugLevel_ = defaultLevelConsole;
     214        this->registerOutputListener(this->consoleWriter_);
    182215
    183216        this->output_  = new MemoryLogWriter();
     
    225258    }
    226259
     260    void OutputHandler::disableCout()
     261    {
     262        this->unregisterOutputListener(this->consoleWriter_);
     263    }
     264
     265    void OutputHandler::enableCout()
     266    {
     267        this->registerOutputListener(this->consoleWriter_);
     268    }
     269
    227270    OutputHandler::OutputVectorIterator OutputHandler::getOutputVectorBegin() const
    228271    {
  • code/branches/console/src/libraries/util/OutputHandler.h

    r6004 r6015  
    7474    // Forward declarations for classes in the source file
    7575    class LogFileWriter;
     76    class ConsoleWriter;
    7677    class MemoryLogWriter;
    7778
     
    129130            //! Set the log path once the program has been properly initialised
    130131            void setLogPath(const std::string& path);
     132            //! Disables the std::cout stream for output
     133            void disableCout();
     134            //! Enables the std::cout stream for output (startup behaviour)
     135            void enableCout();
    131136
    132137            //! Sets the level of the incoming output and returns the OutputHandler
     
    210215            OutputHandler(const OutputHandler& rhs); //! Unused and undefined
    211216
    212             std::list<OutputListener*> listeners_; //!< Array with all registered output listeners
    213             int outputLevel_;                      //!< The level of the incoming output
    214             LogFileWriter* logFile_;               //!< Listener that writes to the log file
    215             MemoryLogWriter* output_;              //!< Listener that Stores ALL output below the current soft debug level
    216             static int softDebugLevel_s;           //!< Maximum of all soft debug levels. @note This is only static for faster access
     217            std::list<OutputListener*> listeners_;        //!< Array with all registered output listeners
     218            int                        outputLevel_;      //!< The level of the incoming output
     219            LogFileWriter*             logFile_;          //!< Listener that writes to the log file
     220            ConsoleWriter*             consoleWriter_;    //!< Listener for std::cout (just program beginning)
     221            MemoryLogWriter*           output_;           //!< Listener that Stores ALL output below the current soft debug level
     222            static int                 softDebugLevel_s;  //!< Maximum of all soft debug levels. @note This is only static for faster access
    217223    };
    218224
Note: See TracChangeset for help on using the changeset viewer.