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

    r8729 r8858  
    3737#include <loki/ScopeGuard.h>
    3838
    39 #include "util/Debug.h"
     39#include "util/Output.h"
    4040#include "util/Exception.h"
    4141#include "Resource.h"
     
    9696        else
    9797        {
    98             COUT(2) << "LuaState: Cannot include file '" << filename << "' (not found)." << std::endl;
     98            orxout(internal_warning, context::lua) << "LuaState: Cannot include file '" << filename << "' (not found)." << endl;
    9999            return false;
    100100        }
     
    136136        else
    137137        {
    138             COUT(2) << "LuaState: Cannot do file '" << filename << "' (not found)." << std::endl;
     138            orxout(internal_warning, context::lua) << "LuaState: Cannot do file '" << filename << "' (not found)." << endl;
    139139            return false;
    140140        }
     
    176176        {
    177177        case LUA_ERRSYNTAX: // Syntax error
    178             COUT(1) << "Lua syntax error: " << lua_tostring(luaState_, -1) << std::endl;
     178            orxout(internal_error, context::lua) << "Lua syntax error: " << lua_tostring(luaState_, -1) << endl;
    179179            break;
    180180        case LUA_ERRMEM:    // Memory allocation error
    181             COUT(1) << "Lua memory allocation error: Consult your dentist immediately!" << std::endl;
     181            orxout(internal_error, context::lua) << "Lua memory allocation error: Consult your dentist immediately!" << endl;
    182182            break;
    183183        }
     
    200200                    std::string errorString = lua_tostring(this->luaState_, -1);
    201201                    if (errorString.find("Error propagation") == std::string::npos)
    202                         COUT(1) << "Lua runtime error: " << errorString << std::endl;
     202                        orxout(internal_error, context::lua) << "Lua runtime error: " << errorString << endl;
    203203                }
    204204                break;
    205205            case LUA_ERRERR: // Error in the error handler
    206                 COUT(1) << "Lua error in error handler. No message available." << std::endl;
     206                orxout(internal_error, context::lua) << "Lua error in error handler. No message available." << endl;
    207207                break;
    208208            case LUA_ERRMEM: // Memory allocation error
    209                 COUT(1) << "Lua memory allocation error: Consult your dentist immediately!" << std::endl;
     209                orxout(internal_error, context::lua) << "Lua memory allocation error: Consult your dentist immediately!" << endl;
    210210                break;
    211211            }
     
    236236    }
    237237
    238     void LuaState::luaLog(unsigned int level, const std::string& message)
    239     {
    240         OutputHandler::getOutStream(level) << message << std::endl;
     238    void LuaState::luaOutput(OutputLevel level, const std::string& context, const std::string& message)
     239    {
     240        orxout(level, registerContext(context)) << message << endl;
     241    }
     242
     243    void LuaState::luaOutput(OutputLevel level, const std::string& message)
     244    {
     245        orxout(level, context::lua) << message << endl;
     246    }
     247
     248    void LuaState::luaOutput(const std::string& message)
     249    {
     250        orxout(debug_output, context::lua) << message << endl;
    241251    }
    242252
     
    288298            if (it->first == name || it->second == function)
    289299            {
    290                 COUT(2) << "Warning: Trying to add a Tolua interface with the same name or function." << std::endl;
     300                orxout(internal_warning, context::lua) << "Trying to add a Tolua interface with the same name or function." << endl;
    291301                return true;
    292302            }
     
    307317        if (it == getToluaInterfaces().end())
    308318        {
    309             COUT(2) << "Warning: Cannot remove Tolua interface '" << name << "': Not found" << std::endl;
     319            orxout(internal_warning, context::lua) << "Cannot remove Tolua interface '" << name << "': Not found" << endl;
    310320            return true;
    311321        }
Note: See TracChangeset for help on using the changeset viewer.