Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 27, 2007, 4:58:52 PM (16 years ago)
Author:
landauf
Message:

introduced 3 different soft debug levels: one for each output device (console, logfile, ingame-shell (to come))
all are configurable in the config file

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/FICN/src/orxonox/core/OutputHandler.cc

    r685 r699  
    2727
    2828#include "OutputHandler.h"
     29#include "DebugLevel.h"
    2930
    3031namespace orxonox
     
    6162
    6263    /**
     64        @brief Returns the soft debug level for a given output device.
     65        @param device The output device
     66        @return The debug level
     67    */
     68    int OutputHandler::getSoftDebugLevel(OutputHandler::OutputDevice device)
     69    {
     70        return DebugLevel::getSoftDebugLevel(device);
     71    }
     72
     73    /**
    6374        @brief Overloaded << operator, redirects the output to the console and the logfile.
    6475        @param sb The streambuffer that should be shown in the console
     
    6778    OutputHandler& OutputHandler::operator<<(std::streambuf* sb)
    6879    {
    69         std::cout << sb;
    70         this->logfile_ << sb;
    71         this->logfile_.flush();
     80        if (getSoftDebugLevel(OutputHandler::LD_Console) >= this->outputLevel_)
     81            std::cout << sb;
     82
     83        if (getSoftDebugLevel(OutputHandler::LD_Logfile) >= this->outputLevel_)
     84        {
     85            this->logfile_ << sb;
     86            this->logfile_.flush();
     87        }
     88
    7289        return *this;
    7390    }
     
    8097    OutputHandler& OutputHandler::operator<<(std::ostream& (*manipulator)(std::ostream&))
    8198    {
    82         manipulator(std::cout);
    83         manipulator(this->logfile_);
    84         this->logfile_.flush();
     99        if (getSoftDebugLevel(OutputHandler::LD_Console) >= this->outputLevel_)
     100            manipulator(std::cout);
     101
     102        if (getSoftDebugLevel(OutputHandler::LD_Logfile) >= this->outputLevel_)
     103        {
     104            manipulator(this->logfile_);
     105            this->logfile_.flush();
     106        }
     107
    85108        return *this;
    86109    }
     
    93116    OutputHandler& OutputHandler::operator<<(std::ios& (*manipulator)(std::ios&))
    94117    {
    95         manipulator(std::cout);
    96         manipulator(this->logfile_);
    97         this->logfile_.flush();
     118        if (getSoftDebugLevel(OutputHandler::LD_Console) >= this->outputLevel_)
     119            manipulator(std::cout);
     120
     121        if (getSoftDebugLevel(OutputHandler::LD_Logfile) >= this->outputLevel_)
     122        {
     123            manipulator(this->logfile_);
     124            this->logfile_.flush();
     125        }
     126
    98127        return *this;
    99128    }
     
    106135    OutputHandler& OutputHandler::operator<<(std::ios_base& (*manipulator)(std::ios_base&))
    107136    {
    108         manipulator(std::cout);
    109         manipulator(this->logfile_);
    110         this->logfile_.flush();
     137        if (getSoftDebugLevel(OutputHandler::LD_Console) >= this->outputLevel_)
     138            manipulator(std::cout);
     139
     140        if (getSoftDebugLevel(OutputHandler::LD_Logfile) >= this->outputLevel_)
     141        {
     142            manipulator(this->logfile_);
     143            this->logfile_.flush();
     144        }
     145
    111146        return *this;
    112147    }
    113 
    114     /**
    115         @brief Overloaded non-member << operator, redirects the output to the console and the logfile.
    116         @param output The value that should be shown in the console
    117         @return A reference to the OutputHandler itself
    118     *//*
    119     OutputHandler& operator<<(OutputHandler& out, char c)
    120     {
    121         std::cout << c;
    122         out.getLogfile() << c;
    123         out.getLogfile().flush();
    124         return out;
    125     }*/
    126 
    127     /**
    128         @brief Overloaded non-member << operator, redirects the output to the console and the logfile.
    129         @param output The value that should be shown in the console
    130         @return A reference to the OutputHandler itself
    131     *//*
    132     OutputHandler& operator<<(OutputHandler& out, signed char c)
    133     {
    134         std::cout << c;
    135         out.getLogfile() << c;
    136         out.getLogfile().flush();
    137         return out;
    138     }*/
    139 
    140     /**
    141         @brief Overloaded non-member << operator, redirects the output to the console and the logfile.
    142         @param output The value that should be shown in the console
    143         @return A reference to the OutputHandler itself
    144     *//*
    145     OutputHandler& operator<<(OutputHandler& out, unsigned char c)
    146     {
    147         std::cout << c;
    148         out.getLogfile() << c;
    149         out.getLogfile().flush();
    150         return out;
    151     }*/
    152 
    153     /**
    154         @brief Overloaded non-member << operator, redirects the output to the console and the logfile.
    155         @param output The value that should be shown in the console
    156         @return A reference to the OutputHandler itself
    157     *//*
    158     OutputHandler& operator<<(OutputHandler& out, const char* s)
    159     {
    160         std::cout << s;
    161         out.getLogfile() << s;
    162         out.getLogfile().flush();
    163         return out;
    164     }*/
    165 
    166     /**
    167         @brief Overloaded non-member << operator, redirects the output to the console and the logfile.
    168         @param output The value that should be shown in the console
    169         @return A reference to the OutputHandler itself
    170     *//*
    171     OutputHandler& operator<<(OutputHandler& out, const signed char* s)
    172     {
    173         std::cout << s;
    174         out.getLogfile() << s;
    175         out.getLogfile().flush();
    176         return out;
    177     }*/
    178 
    179     /**
    180         @brief Overloaded non-member << operator, redirects the output to the console and the logfile.
    181         @param output The value that should be shown in the console
    182         @return A reference to the OutputHandler itself
    183     *//*
    184     OutputHandler& operator<<(OutputHandler& out, const unsigned char* s)
    185     {
    186         std::cout << s;
    187         out.getLogfile() << s;
    188         out.getLogfile().flush();
    189         return out;
    190     }*/
    191  }
     148}
Note: See TracChangeset for help on using the changeset viewer.