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

    r8366 r8858  
    3434
    3535#include "SpecialConfig.h"
    36 #include "util/Debug.h"
     36#include "util/Output.h"
    3737#include "util/Exception.h"
    3838#include "util/StringUtils.h"
     
    106106            }
    107107            catch (Tcl::tcl_error const &e)
    108             {   COUT(1) << "Tcl error while creating Tcl-interpreter: " << e.what() << std::endl;   }
     108            {   orxout(internal_error, context::tcl) << "Tcl error while creating Tcl-interpreter: " << e.what() << endl;   }
    109109        }
    110110    }
     
    129129        }
    130130        catch (Tcl::tcl_error const &e)
    131         {   COUT(1) << "Tcl error while creating Tcl-interpreter: " << e.what() << std::endl; COUT(1) << "Error: Tcl isn't properly initialized. Orxonox might possibly not work like that." << std::endl;   }
     131        {
     132            orxout(internal_error, context::tcl) << "Tcl error while creating Tcl-interpreter: " << e.what() << endl;
     133            orxout(user_error, context::tcl) << "Tcl isn't properly initialized. Orxonox might possibly not work like that." << endl;
     134        }
    132135
    133136        return interpreter;
     
    154157    std::string TclBind::tcl_query(Tcl::object const &args)
    155158    {
    156         COUT(4) << "Tcl_query: " << args.get() << std::endl;
     159        orxout(verbose, context::commands) << "Tcl_query: " << args.get() << endl;
    157160        return TclBind::tcl_helper(args, true);
    158161    }
     
    163166    void TclBind::tcl_execute(Tcl::object const &args)
    164167    {
    165         COUT(4) << "Tcl_execute: " << args.get() << std::endl;
     168        orxout(verbose, context::commands) << "Tcl_execute: " << args.get() << endl;
    166169        TclBind::tcl_helper(args, false);
    167170    }
     
    184187            error = evaluation.execute();
    185188
    186         switch (error)
    187         {
    188             case CommandExecutor::Error:       COUT(1) << "Error: Can't execute command \"" << command << "\", command doesn't exist. (B)" << std::endl; break;
    189             case CommandExecutor::Incomplete:  COUT(1) << "Error: Can't execute command \"" << command << "\", not enough arguments given. (B)" << std::endl; break;
    190             case CommandExecutor::Deactivated: COUT(1) << "Error: Can't execute command \"" << command << "\", command is not active. (B)" << std::endl; break;
    191             case CommandExecutor::Denied:      COUT(1) << "Error: Can't execute command \"" << command << "\", access denied. (B)" << std::endl; break;
    192         }
    193 
    194         if (error == CommandExecutor::Error)
    195             COUT(3) << "Did you mean \"" << evaluation.getCommandSuggestion() << "\"?" << std::endl;
     189        if (error)
     190        {
     191            orxout(user_error) << "Can't execute command \"" << command << "\", " + CommandExecutor::getErrorDescription(error) + ". (TclBind)" << endl;
     192            if (error == CommandExecutor::Inexistent)
     193                orxout(user_info) << "Did you mean \"" << evaluation.getCommandSuggestion() << "\"?" << endl;
     194        }
    196195
    197196        return result;
     
    211210            }
    212211            catch (Tcl::tcl_error const &e)
    213             {   COUT(1) << "Tcl error: " << e.what() << std::endl;   }
     212            {   orxout(user_error, context::tcl) << "Tcl error: " << e.what() << endl;   }
    214213        }
    215214
     
    223222    void TclBind::bgerror(const std::string& error)
    224223    {
    225         COUT(1) << "Tcl background error: " << stripEnclosingBraces(error) << std::endl;
     224        orxout(user_error, context::tcl) << "Tcl background error: " << stripEnclosingBraces(error) << endl;
    226225    }
    227226
     
    243242        }
    244243        catch (Tcl::tcl_error const &e)
    245         {   COUT(1) << "Tcl error: " << e.what() << std::endl;   }
     244        {   orxout(user_error, context::tcl) << "Tcl error: " << e.what() << endl;   }
    246245
    247246        if (error)
Note: See TracChangeset for help on using the changeset viewer.