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/network/MasterServerComm.cc

    r8351 r8858  
    2828
    2929#include "MasterServerComm.h"
    30 #include "util/Debug.h"
     30#include "util/Output.h"
     31#include "WANDiscovery.h"
    3132
    3233namespace orxonox
     
    4445    /* initialize Enet */
    4546    if( enet_initialize () != 0 )
    46     { COUT(1) << "An error occurred while initializing ENet.\n";
     47    { orxout(internal_error, context::master_server) << "An error occurred while initializing ENet." << endl;
    4748      return 1;
    4849    }
     
    6162    /* see if it worked */
    6263    if (this->client == NULL)
    63     { COUT(1) << "An error occurred while trying to create an "
    64         << "ENet client host.\n";
     64    { orxout(internal_error, context::master_server) << "An error occurred while trying to create an "
     65        << "ENet client host." << endl;
    6566      return 1;
    6667    }
     
    8586
    8687    if( this->peer == NULL )
    87     { COUT(2) << "ERROR: No available peers for initiating an ENet"
    88         << " connection.\n";
     88    { orxout(internal_error, context::master_server) << "No available peers for initiating an ENet"
     89        << " connection." << endl;
    8990      return -1;
    9091    }
     
    9394    if (enet_host_service (this->client, &this->event, 500) > 0 &&
    9495        this->event.type == ENET_EVENT_TYPE_CONNECT )
    95       COUT(3) << "Connection to master server succeeded.\n";
     96      orxout(internal_info, context::master_server) << "Connection to master server succeeded." << endl;
    9697    else
    9798    {
    9899      enet_peer_reset (this->peer);
    99       COUT(2) << "ERROR: connection to " << address << " failed.\n";
     100      orxout(internal_warning, context::master_server) << "Connection to " << address << " failed." << endl;
    100101      return -1;
    101102    }
     
    128129
    129130        case ENET_EVENT_TYPE_DISCONNECT:
    130           COUT(4) << "Disconnect from master server successful.\n";
     131          orxout(verbose, context::master_server) << "Disconnect from master server successful." << endl;
    131132          return 0;
    132133        default: break;
     
    149150   * so we can also make callbacks from objects
    150151   */
    151   int MasterServerComm::pollForReply( int (*callback)( char*, ENetEvent* ),
    152     int delayms )
     152  int MasterServerComm::pollForReply( WANDiscovery* listener, int delayms )
    153153  {
    154154    /* see whether anything happened */
    155155    /* WORK MARK REMOVE THIS OUTPUT */
    156     COUT(2) << "polling masterserver...\n";
     156    orxout(verbose, context::master_server) << "polling masterserver..." << endl;
    157157
    158158    /* address buffer */
     
    176176          addrconv = (char *) calloc( 50, 1 );
    177177          if( !addrconv )
    178           { COUT(2) << "MasterServerComm.cc: Could not allocate memory!\n";
     178          { orxout(internal_warning, context::master_server) << "MasterServerComm.cc: Could not allocate memory!" << endl;
    179179            break;
    180180          }
     
    185185
    186186          /* DEBUG */
    187           COUT(3) << "MasterServer Debug: A packet of length "
     187          orxout(verbose, context::master_server) << "MasterServer Debug: A packet of length "
    188188            << this->event.packet->dataLength
    189189            << " containing " << this->event.packet->data
     
    193193
    194194          /* call the supplied callback, if any. */
    195           if( (*callback) != NULL )
    196             retval = (*callback)( addrconv, &(this->event) );
     195          if( listener != NULL )
     196            retval = listener->rhandler( addrconv, &(this->event) );
    197197
    198198          /* clean up */
Note: See TracChangeset for help on using the changeset viewer.