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

    r8351 r8858  
    3838  helper_output_debug( ENetEvent *event, char *addrconv )
    3939  {
    40     COUT(4) << "A packet of length"
     40    orxout(verbose, context::master_server)
     41      << "A packet of length"
    4142      << event->packet->dataLength
    4243      << " containing "
     
    4546      << addrconv
    4647      << " on channel "
    47       << event->channelID << "\n";
     48      << event->channelID << endl;
    4849  }
    4950
     
    6667          + MSPROTO_SERVERLIST_ITEM_LEN + 2,1 );
    6768      if( !tosend )
    68       { COUT(2) << "Masterserver.cc: Memory allocation failed.\n";
     69      { orxout(internal_warning, context::master_server) << "Masterserver.cc: Memory allocation failed." << endl;
    6970        continue;
    7071      }
     
    108109  { /* check for bad parameters */
    109110    if( !event )
    110     { COUT(2) << "MasterServer::eventConnect: No event given.\n" ;
     111    { orxout(internal_warning, context::master_server) << "MasterServer::eventConnect: No event given." << endl;
    111112      return -1;
    112113    }
     
    117118
    118119    /* output debug info */
    119     COUT(4) << "A new client connected from "
     120    orxout(verbose, context::master_server) << "A new client connected from "
    120121      << addrconv
    121122      << " on port "
    122       << event->peer->address.port << "\n";
     123      << event->peer->address.port << endl;
    123124
    124125    /* store string form of address here */
     
    134135  { /* check for bad parameters */
    135136    if( !event )
    136     { COUT(2) << "No event given.\n";
     137    { orxout(internal_warning, context::master_server) << "No event given." << endl;
    137138      return -1;
    138139    }
    139140
    140141    /* output that the disconnect happened */
    141     COUT(4) << (char*)event->peer->data << " disconnected.\n";
     142    orxout(verbose, context::master_server) << (char*)event->peer->data << " disconnected." << endl;
    142143
    143144    /* create string from peer data */
     
    159160  { /* validate packet */
    160161    if( !event || !(event->packet) || !(event->peer) )
    161     { COUT(2) << "No complete event given.\n";
     162    { orxout(internal_warning, context::master_server) << "No complete event given." << endl;
    162163      return -1;
    163164    }
     
    182183       
    183184        /* tell people we did so */
    184         COUT(2) << "Added new server to list: " <<
    185           packet::ServerInformation( event ).getServerIP() << "\n";
     185        orxout(internal_info, context::master_server) << "Added new server to list: " <<
     186          packet::ServerInformation( event ).getServerIP() << endl;
    186187      }
    187188
     
    197198
    198199        /* tell the user */
    199         COUT(2) << "Removed server " << name << " from list.\n";
     200        orxout(internal_info, context::master_server) << "Removed server " << name << " from list." << endl;
    200201      }
    201202
     
    230231    if( event == NULL )
    231232    {
    232       COUT(1) << "Could not create ENetEvent structure, exiting.\n";
     233      orxout(user_error, context::master_server) << "Could not create ENetEvent structure, exiting." << endl;
    233234      exit( EXIT_FAILURE );
    234235    }
     
    263264    /***** INITIALIZE NETWORKING *****/
    264265    if( enet_initialize () != 0)
    265     { COUT(1) << "An error occurred while initializing ENet.\n";
     266    { orxout(user_error, context::master_server) << "An error occurred while initializing ENet." << endl;
    266267      exit( EXIT_FAILURE );
    267268    }
     
    285286    /* see if creation worked */
    286287    if( !this->server )
    287     { COUT(1) <<
    288         "An error occurred while trying to create an ENet server host.\n";
     288    { orxout(user_error, context::master_server) <<
     289        "An error occurred while trying to create an ENet server host." << endl;
    289290      exit( EXIT_FAILURE );
    290291    }
     
    294295
    295296    /* tell people we're now initialized */
    296     COUT(0) << "MasterServer initialized, waiting for connections.\n";
     297    orxout(internal_status, context::master_server) << "MasterServer initialized, waiting for connections." << endl;
    297298  }
    298299
Note: See TracChangeset for help on using the changeset viewer.