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/util/SignalHandler.cc

    r8351 r8858  
    3939#include <cstdio>
    4040
    41 #include "Debug.h"
     41#include "Output.h"
    4242
    4343namespace orxonox
     
    127127      if( SignalHandler::singletonPtr_s == 0 )
    128128      {
    129         COUT(0) << "Received signal " << sigName.c_str() << std::endl << "Can't write backtrace because SignalHandler is already destroyed" << std::endl;
     129        orxout(user_error) << "Received signal " << sigName.c_str() << endl << "Can't write backtrace because SignalHandler is already destroyed" << endl;
    130130        exit(EXIT_FAILURE);
    131131      }
     
    137137
    138138
    139       COUT(0) << "Received signal " << sigName.c_str() << std::endl << "Try to write backtrace to file orxonox_crash.log" << std::endl;
     139      orxout(user_error) << "Received signal " << sigName.c_str() << endl << "Try to write backtrace to file orxonox_crash.log" << endl;
    140140
    141141     
     
    206206#ifdef PR_SET_PTRACER
    207207        if( prctl(PR_SET_PTRACER, gdbPid, 0, 0, 0) == -1 )
    208           COUT(0) << "could not set proper permissions for GDB to attach to process..." << endl;
     208          orxout(user_error) << "could not set proper permissions for GDB to attach to process..." << endl;
    209209#endif
    210210       
     
    213213
    214214        if( read( sigPipe[0], &someData, sizeof(someData) ) != sizeof(someData) )
    215           COUT(0) << "something went wrong :(" << std::endl;
     215          orxout(user_error) << "something went wrong :(" << endl;
    216216
    217217        if ( someData != 0x12345678 )
    218218        {
    219           COUT(0) << "something went wrong :(" << std::endl;
     219          orxout(user_error) << "something went wrong :(" << endl;
    220220        }
    221221
     
    328328      if ( fwrite( bt.c_str(), 1, bt.length(), f ) != bt.length() )
    329329      {
    330         COUT(0) << "could not write " << bt.length() << " byte to " << getInstance().filename << std::endl;
     330        orxout(user_error) << "could not write " << bt.length() << " byte to " << getInstance().filename << endl;
    331331        exit(EXIT_FAILURE);
    332332      }
     
    364364_UtilExport void __cdecl abort()
    365365{
    366     COUT(1) << "This application has requested the Runtime to terminate it in an unusual way." << std::endl;
    367     COUT(1) << "Please contact the application's support team for more information." << std::endl;
     366    using namespace orxonox;
     367    orxout(user_error) << "This application has requested the Runtime to terminate it in an unusual way." << endl;
     368    orxout(user_error) << "Please contact the application's support team for more information." << endl;
    368369    DebugBreak();
    369370    exit(0x3);
     
    373374_UtilExport void __cdecl _assert(const char* expression, const char* file, int line)
    374375{
    375     COUT(1) << "Assertion failed: " << expression << ", file " << file << ", line " << line << std::endl;
    376     COUT(1) << std::endl;
     376    using namespace orxonox;
     377    orxout(user_error) << "Assertion failed: " << expression << ", file " << file << ", line " << line << endl;
     378    orxout(user_error) << endl;
    377379    abort();
    378380}
     
    423425            bExecuting = true;
    424426
    425             COUT(1) << std::endl;
     427            orxout(user_error) << endl;
    426428
    427429            // if the signalhandler has already been destroyed then don't do anything
    428430            if (SignalHandler::singletonPtr_s == 0)
    429431            {
    430                 COUT(1) << "Caught an unhandled exception" << std::endl << "Can't write backtrace because SignalHandler is already destroyed" << std::endl;
     432                orxout(user_error) << "Caught an unhandled exception" << endl << "Can't write backtrace because SignalHandler is already destroyed" << endl;
    431433                exit(EXIT_FAILURE);
    432434            }
    433435
    434             COUT(1) << "Caught an unhandled exception" << std::endl << "Try to write backtrace to orxonox_crash.log..." << std::endl;
     436            orxout(user_error) << "Caught an unhandled exception" << endl << "Try to write backtrace to orxonox_crash.log..." << endl;
    435437
    436438            // write the crash log
     
    439441            time_t now = time(NULL);
    440442
    441             crashlog << "=======================================================" << std::endl;
     443            crashlog << "=======================================================" << endl;
    442444            crashlog << "= Time: " << std::string(ctime(&now));
    443             crashlog << "=======================================================" << std::endl;
    444             crashlog << std::endl;
     445            crashlog << "=======================================================" << endl;
     446            crashlog << endl;
    445447
    446448            const std::string& error = SignalHandler::getExceptionType(pExceptionInfo);
    447449
    448             crashlog << error << std::endl;
    449             crashlog << std::endl;
     450            crashlog << error << endl;
     451            crashlog << endl;
    450452
    451453            const std::string& callstack = SignalHandler::getStackTrace(pExceptionInfo);
    452454
    453             crashlog << "Call stack:" << std::endl;
    454             crashlog << callstack << std::endl;
     455            crashlog << "Call stack:" << endl;
     456            crashlog << callstack << endl;
    455457
    456458            crashlog.close();
    457459
    458460            // print the same information also to the console
    459             COUT(1) << std::endl;
    460             COUT(1) << error << std::endl;
    461             COUT(1) << std::endl;
    462             COUT(1) << "Call stack:" << std::endl;
    463             COUT(1) << callstack << std::endl;
     461            orxout(user_error) << endl;
     462            orxout(user_error) << error << endl;
     463            orxout(user_error) << endl;
     464            orxout(user_error) << "Call stack:" << endl;
     465            orxout(user_error) << callstack << endl;
    464466
    465467            bExecuting = false;
     
    467469        else
    468470        {
    469             COUT(1) << "An error occurred while writing the backtrace" << std::endl;
     471            orxout(user_error) << "An error occurred while writing the backtrace" << endl;
    470472        }
    471473
Note: See TracChangeset for help on using the changeset viewer.