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/Loader.cc

    r8108 r8858  
    3333#include <boost/scoped_ptr.hpp>
    3434
    35 #include "util/Debug.h"
     35#include "util/Output.h"
    3636#include "util/Exception.h"
    3737#include "util/StringUtils.h"
     
    4949    ClassTreeMask Loader::currentMask_s;
    5050
    51     bool Loader::open(const XMLFile* file, const ClassTreeMask& mask)
     51    bool Loader::open(const XMLFile* file, const ClassTreeMask& mask, bool bVerbose)
    5252    {
    5353        Loader::add(file, mask);
    54         return Loader::load(file, mask);
     54        return Loader::load(file, mask, bVerbose);
    5555    }
    5656
     
    9393    @param mask
    9494        A ClassTreeMask, which defines which types of classes are loaded and which aren't.
    95     @param verbose
     95    @param bVerbose
    9696        Whether the loader is verbose (prints its progress in a low output level) or not.
    9797    @return
    9898        Returns true if successful.
    9999    */
    100     bool Loader::load(const ClassTreeMask& mask, bool verbose)
     100    bool Loader::load(const ClassTreeMask& mask, bool bVerbose)
    101101    {
    102102        bool success = true;
    103103        for (std::vector<std::pair<const XMLFile*, ClassTreeMask> >::iterator it = Loader::files_s.begin(); it != Loader::files_s.end(); ++it)
    104             if (!Loader::load(it->first, it->second * mask, verbose))
     104            if (!Loader::load(it->first, it->second * mask, bVerbose))
    105105                success = false;
    106106
     
    124124    @param mask
    125125        A ClassTreeMask, which defines which types of classes are reloaded and which aren't.
    126     @param verbose
     126    @param bVerbose
    127127        Whether the loader is verbose (prints its progress in a low output level) or not.
    128128    @return
    129129        Returns true if successful.
    130130    */
    131     bool Loader::reload(const ClassTreeMask& mask, bool verbose)
     131    bool Loader::reload(const ClassTreeMask& mask, bool bVerbose)
    132132    {
    133133        Loader::unload(mask);
    134         return Loader::load(mask, verbose);
     134        return Loader::load(mask, bVerbose);
    135135    }
    136136
     
    142142    @param mask
    143143        A ClassTreeMask, which defines which types of classes are loaded and which aren't.
    144     @param verbose
     144    @param bVerbose
    145145        Whether the loader is verbose (prints its progress in a low output level) or not.
    146146    @param bRemoveLuaTags
     
    149149        Returns true if successful.
    150150    */
    151     bool Loader::load(const XMLFile* file, const ClassTreeMask& mask, bool verbose, bool bRemoveLuaTags)
     151    bool Loader::load(const XMLFile* file, const ClassTreeMask& mask, bool bVerbose, bool bRemoveLuaTags)
    152152    {
    153153        if (!file)
     
    170170            if (info == NULL)
    171171            {
    172                 COUT(1) << "Error: Could not find XML file '" << file->getFilename() << "'." << std::endl;
     172                orxout(user_error, context::loader) << "Could not find XML file '" << file->getFilename() << "'." << endl;
    173173                return false;
    174174            }
     
    187187        try
    188188        {
    189             if(verbose)
    190             {
    191                 COUT(0) << "Start loading " << file->getFilename() << "..." << std::endl;
    192                 COUT(3) << "Mask: " << Loader::currentMask_s << std::endl;
    193             }
    194             else
    195             {
    196                 COUT(4) << "Start loading " << file->getFilename() << "..." << std::endl;
    197                 COUT(4) << "Mask: " << Loader::currentMask_s << std::endl;
     189            if(bVerbose)
     190            {
     191                orxout(user_info) << "Start loading " << file->getFilename() << "..." << endl;
     192                orxout(internal_info, context::loader) << "Mask: " << Loader::currentMask_s << endl;
     193            }
     194            else
     195            {
     196                orxout(verbose, context::loader) << "Start loading " << file->getFilename() << "..." << endl;
     197                orxout(verbose_more, context::loader) << "Mask: " << Loader::currentMask_s << endl;
    198198            }
    199199
     
    208208                rootElement.InsertEndChild(*child);
    209209
    210             COUT(4) << "  creating root-namespace..." << std::endl;
     210            orxout(verbose, context::loader) << "  creating root-namespace..." << endl;
    211211            Namespace* rootNamespace = new Namespace(0);
    212212            rootNamespace->setLoaderIndentation("    ");
     
    216216            rootNamespace->XMLPort(rootElement, XMLPort::LoadObject);
    217217
    218             if(verbose)
    219                 COUT(0) << "Finished loading " << file->getFilename() << '.' << std::endl;
    220             else
    221                 COUT(4) << "Finished loading " << file->getFilename() << '.' << std::endl;
    222 
    223             COUT(4) << "Namespace-tree:" << std::endl << rootNamespace->toString("  ") << std::endl;
     218            if(bVerbose)
     219                orxout(user_info) << "Finished loading " << file->getFilename() << '.' << endl;
     220            else
     221                orxout(verbose, context::loader) << "Finished loading " << file->getFilename() << '.' << endl;
     222
     223            orxout(verbose, context::loader) << "Namespace-tree:" << '\n' << rootNamespace->toString("  ") << endl;
    224224
    225225            return true;
     
    227227        catch (ticpp::Exception& ex)
    228228        {
    229             COUT(1) << std::endl;
    230             COUT(1) << "An XML-error occurred in Loader.cc while loading " << file->getFilename() << ':' << std::endl;
    231             COUT(1) << ex.what() << std::endl;
    232             COUT(1) << "Loading aborted." << std::endl;
     229            orxout(user_error, context::loader) << endl;
     230            orxout(user_error, context::loader) << "An XML-error occurred in Loader.cc while loading " << file->getFilename() << ':' << endl;
     231            orxout(user_error, context::loader) << ex.what() << endl;
     232            orxout(user_error, context::loader) << "Loading aborted." << endl;
    233233            return false;
    234234        }
    235235        catch (Exception& ex)
    236236        {
    237             COUT(1) << std::endl;
    238             COUT(1) << "A loading-error occurred in Loader.cc while loading " << file->getFilename() << ':' << std::endl;
    239             COUT(1) << ex.what() << std::endl;
    240             COUT(1) << "Loading aborted." << std::endl;
     237            orxout(user_error, context::loader) << endl;
     238            orxout(user_error, context::loader) << "A loading-error occurred in Loader.cc while loading " << file->getFilename() << ':' << endl;
     239            orxout(user_error, context::loader) << ex.what() << endl;
     240            orxout(user_error, context::loader) << "Loading aborted." << endl;
    241241            return false;
    242242        }
    243243        catch (...)
    244244        {
    245             COUT(1) << std::endl;
    246             COUT(1) << "An error occurred in Loader.cc while loading " << file->getFilename() << ':' << std::endl;
    247             COUT(1) << Exception::handleMessage() << std::endl;
    248             COUT(1) << "Loading aborted." << std::endl;
     245            orxout(user_error, context::loader) << endl;
     246            orxout(user_error, context::loader) << "An error occurred in Loader.cc while loading " << file->getFilename() << ':' << endl;
     247            orxout(user_error, context::loader) << Exception::handleMessage() << endl;
     248            orxout(user_error, context::loader) << "Loading aborted." << endl;
    249249            return false;
    250250        }
     
    271271    @param mask
    272272        A ClassTreeMask, which defines which types of classes are reloaded and which aren't.
    273     @param verbose
     273    @param bVerbose
    274274        Whether the loader is verbose (prints its progress in a low output level) or not.
    275275    @return
    276276        Returns true if successful.
    277277    */
    278     bool Loader::reload(const XMLFile* file, const ClassTreeMask& mask, bool verbose)
     278    bool Loader::reload(const XMLFile* file, const ClassTreeMask& mask, bool bVerbose)
    279279    {
    280280        Loader::unload(file, mask);
    281         return Loader::load(file, mask, verbose);
     281        return Loader::load(file, mask, bVerbose);
    282282    }
    283283
     
    337337            if (!expectedValue)
    338338            {
    339                 COUT(2) << "Warning: Error in level file" << std::endl;
     339                orxout(internal_error, context::loader) << "Error in level file" << endl;
    340340                // TODO: error handling
    341                 return false; 
     341                return false;
    342342            }
    343343        }
Note: See TracChangeset for help on using the changeset viewer.