Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 4, 2011, 2:47:44 AM (13 years ago)
Author:
rgrieder
Message:

Merged unity_build branch back to trunk.

Features:

  • Implemented fully automatic build units to speed up compilation if requested
  • Added DOUT macro for quick debug output
  • Activated text colouring in the POSIX IOConsole
  • DeclareToluaInterface is not necessary anymore

Improvements:

  • Output levels now change appropriately when switch back and forth from dev mode
  • Log level for the file output is now also correct during startup
  • Removed some header file dependencies in core and tools to speed up compilation

no more file for command line options

  • Improved util::tribool by adapting some concepts from boost::tribool

Regressions:

  • It is not possible anymore to specify command line arguments in an extra file because we've got config values for that purpose.
Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/libraries/util/OutputHandler.h

    r7401 r8729  
    3939#include "UtilPrereqs.h"
    4040
    41 #include <list>
    4241#include <ostream>
    4342#include <string>
     
    6362        enum Value
    6463        {
     64            TDebug  = -1,
    6565            None    = 0,
    6666            Error   = 1,
     
    103103                { return OutputHandler::getInstance().setOutputLevel(level); }
    104104
    105             typedef std::vector<std::pair<int, std::string> >::const_iterator OutputVectorIterator;
    106             //! Returns an iterator to the beginning of the all-output vector
    107             OutputVectorIterator getOutputVectorBegin() const;
    108             //! Returns an iterator to the end of the all-output vector
    109             OutputVectorIterator getOutputVectorEnd() const;
     105            typedef std::vector<std::pair<int, std::string> > OutputVector;
     106            //! Returns all output written so far (empty if disableMemoryLog() was called)
     107            const OutputVector& getOutput() const;
    110108
    111109            //! Writes to all output devices
     
    136134            //! Set the log path once the program has been properly initialised
    137135            void setLogPath(const std::string& path);
     136            /** Rewrites the log file (completely respects the current debug level).
     137                Once disableMemoryLog() has been called, this function will do nothing.
     138            */
     139            void rewriteLogFile();
     140
    138141            //! Disables the std::cout stream for output
    139142            void disableCout();
    140143            //! Enables the std::cout stream for output (startup behaviour)
    141144            void enableCout();
     145            //! Stop writing to the memory buffer (call this as soon as possible to minimise memory usage)
     146            void disableMemoryLog();
    142147
    143148            //! Sets the level of the incoming output and returns the OutputHandler
     
    213218            inline operator int() const { return 0; }
    214219
    215             //! Name of the OutputListener that writes to the log file
    216             static const std::string logFileOutputListenerName_s;
    217 
    218220        private:
    219221            OutputHandler();
     
    221223            OutputHandler(const OutputHandler& rhs);      //!< Copy-constructor: Unused and undefined
    222224
    223             std::list<OutputListener*> listeners_;        //!< Array with all registered output listeners
    224             int                        outputLevel_;      //!< The level of the incoming output
    225             LogFileWriter*             logFile_;          //!< Listener that writes to the log file
    226             ConsoleWriter*             consoleWriter_;    //!< Listener for std::cout (just program beginning)
    227             MemoryLogWriter*           output_;           //!< Listener that Stores ALL output below the current soft debug level
    228             static int                 softDebugLevel_s;  //!< Maximum of all soft debug levels. @note This is only static for faster access
     225            /// Evaluates the maximum global log level
     226            void updateGlobalDebugLevel();
     227
     228            std::vector<OutputListener*> listeners_;        //!< Array with all registered output listeners
     229            int                          outputLevel_;      //!< The level of the incoming output
     230            LogFileWriter*               logFile_;          //!< Writes output to the log file
     231            ConsoleWriter*               consoleWriter_;    //!< Writes to std::cout (can be disabled)
     232            MemoryLogWriter*             memoryBuffer_;     //!< Writes to memory as a buffer (can/must be stopped at some time)
     233            static int                   softDebugLevel_s;  //!< Maximum of all soft debug levels. @note This is only static for faster access
    229234    };
    230235
     
    251256        //! Returns the name of this output listener
    252257        const std::string& getOutputListenerName() const { return this->name_; }
    253         //! Returns the soft debug level of the listener
    254         int getSoftDebugLevel() const { return this->softDebugLevel_; }
    255         //! Sets the soft debug level of the listener
    256         void setSoftDebugLevel(int level)
    257         {
    258             this->softDebugLevel_ = level;
    259             OutputHandler::getInstance().setSoftDebugLevel(this->name_, level);
    260         }
    261258
    262259    protected:
     
    271268    inline OutputHandler& OutputHandler::output(const T& output)
    272269    {
    273         for (std::list<OutputListener*>::const_iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
     270        for (std::vector<OutputListener*>::const_iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
    274271        {
    275272            if (this->outputLevel_ <= (*it)->softDebugLevel_ && (*it)->outputStream_ != NULL)
Note: See TracChangeset for help on using the changeset viewer.