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:
7 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/libraries/core/input/Button.cc

    r7891 r8858  
    3838#include "util/SubString.h"
    3939#include "util/StringUtils.h"
    40 #include "util/Debug.h"
     40#include "util/Output.h"
    4141#include "core/command/ConsoleCommand.h"
    4242#include "core/command/CommandEvaluation.h"
     
    255255        if (serious)
    256256        {
    257             COUT(2) << "Error while parsing binding for button/axis " << this->name_ << ". "
    258                 << message << std::endl;
     257            orxout(internal_error, context::input) << "Error while parsing binding for button/axis " << this->name_ << ". "
     258                << message << endl;
    259259        }
    260260        else
    261261        {
    262             COUT(3) << "Warning while parsing binding for button/axis " << this->name_ << ". "
    263                 << message << std::endl;
     262            orxout(internal_warning, context::input) << "Warning while parsing binding for button/axis " << this->name_ << ". "
     263                << message << endl;
    264264        }
    265265    }
  • code/trunk/src/libraries/core/input/InputDevice.h

    r8351 r8858  
    4343
    4444#include "util/Clock.h"
    45 #include "util/Debug.h"
     45#include "util/Output.h"
    4646#include "util/Exception.h"
    4747#include "InputState.h"
     
    135135            //       invalid right until the subclass has been constructed!
    136136            oisDevice_->setEventCallback(static_cast<DeviceClass*>(this));
    137             COUT(4) << "Instantiated a " << this->getClassName() << std::endl;
     137            orxout(verbose, context::input) << "Instantiated a " << this->getClassName() << endl;
    138138        }
    139139
     
    147147            catch (const OIS::Exception& ex)
    148148            {
    149                 COUT(1) << this->getClassName() << " destruction failed: " << ex.eText << std::endl
    150                         << "    Potential resource leak!" << std::endl;
     149                orxout(internal_error, context::input) << this->getClassName() << " destruction failed: " << ex.eText << '\n'
     150                                                       << "Potential resource leak!" << endl;
    151151            }
    152152        }
  • code/trunk/src/libraries/core/input/InputManager.cc

    r8729 r8858  
    100100        RegisterRootObject(InputManager);
    101101
    102         CCOUT(4) << "Constructing..." << std::endl;
     102        orxout(internal_status, context::input) << "InputManager: Constructing..." << endl;
    103103
    104104        // Allocate space for the function call buffer
     
    128128        ModifyConsoleCommand(__CC_InputManager_name, __CC_reload_name).setObject(this);
    129129
    130         CCOUT(4) << "Construction complete." << std::endl;
     130        orxout(internal_status, context::input) << "InputManager: Construction complete." << endl;
    131131        internalState_ = Nothing;
    132132    }
     
    143143    void InputManager::loadDevices()
    144144    {
    145         CCOUT(4) << "Loading input devices..." << std::endl;
     145        orxout(verbose, context::input) << "InputManager: Loading input devices..." << endl;
    146146
    147147        // When loading the devices they should not already be loaded
     
    196196            // Exception-safety
    197197            Loki::ScopeGuard guard = Loki::MakeGuard(OIS::InputManager::destroyInputSystem, oisInputManager_);
    198             CCOUT(4) << "Created OIS input manager." << std::endl;
     198            orxout(verbose, context::input) << "Created OIS input manager." << endl;
    199199
    200200            if (oisInputManager_->getNumberOfDevices(OIS::OISKeyboard) > 0)
     
    219219        this->updateActiveStates();
    220220
    221         CCOUT(4) << "Input devices loaded." << std::endl;
     221        orxout(verbose, context::input) << "Input devices loaded." << endl;
    222222    }
    223223
     
    233233            catch (const std::exception& ex)
    234234            {
    235                 CCOUT(2) << "Warning: Failed to create Mouse:" << ex.what() << std::endl
    236                          << "Proceeding without mouse support." << std::endl;
    237             }
    238         }
    239         else
    240             CCOUT(2) << "Warning: No mouse found! Proceeding without mouse support." << std::endl;
     235                orxout(user_warning, context::input) << "Failed to create Mouse:" << ex.what() << '\n'
     236                                                     << "Proceeding without mouse support." << endl;
     237            }
     238        }
     239        else
     240            orxout(user_warning, context::input) << "No mouse found! Proceeding without mouse support." << endl;
    241241    }
    242242
     
    252252            catch (const std::exception& ex)
    253253            {
    254                 CCOUT(2) << "Warning: Failed to create joy stick: " << ex.what() << std::endl;
     254                orxout(user_warning, context::input) << "Failed to create joy stick: " << ex.what() << endl;
    255255            }
    256256        }
     
    270270    InputManager::~InputManager()
    271271    {
    272         CCOUT(3) << "Destroying..." << std::endl;
     272        orxout(internal_status, context::input) << "InputManager: Destroying..." << endl;
    273273
    274274        // Leave all active InputStates (except "empty")
     
    295295        ModifyConsoleCommand(__CC_InputManager_name, __CC_reload_name).setObject(0);
    296296
    297         CCOUT(3) << "Destruction complete." << std::endl;
     297        orxout(internal_status, context::input) << "InputManager: Destruction complete." << endl;
    298298    }
    299299
     
    306306    void InputManager::destroyDevices()
    307307    {
    308         CCOUT(4) << "Destroying devices..." << std::endl;
     308        orxout(verbose, context::input) << "InputManager: Destroying devices..." << endl;
    309309
    310310        BOOST_FOREACH(InputDevice*& device, devices_)
     
    315315            delete device;
    316316            device = 0;
    317             CCOUT(4) << className << " destroyed." << std::endl;
     317            orxout(verbose, context::input) << className << " destroyed." << endl;
    318318        }
    319319        devices_.resize(InputDeviceEnumerator::FirstJoyStick);
     
    326326        catch (const OIS::Exception& ex)
    327327        {
    328             COUT(1) << "OIS::InputManager destruction failed" << ex.eText << std::endl
    329                     << "    Potential resource leak!" << std::endl;
     328            orxout(internal_error, context::input) << "OIS::InputManager destruction failed" << ex.eText << '\n'
     329                                                   << "Potential resource leak!" << endl;
    330330        }
    331331        oisInputManager_ = NULL;
    332332
    333333        internalState_ |= Bad;
    334         CCOUT(4) << "Destroyed devices." << std::endl;
     334        orxout(verbose, context::input) << "Destroyed devices." << endl;
    335335    }
    336336
     
    343343    {
    344344        if (internalState_ & Calibrating)
    345             CCOUT(2) << "Warning: Cannot reload input system. Joy sticks are currently being calibrated." << std::endl;
     345            orxout(internal_warning, context::input) << "Cannot reload input system. Joy sticks are currently being calibrated." << endl;
    346346        else
    347347            reloadInternal();
     
    351351    void InputManager::reloadInternal()
    352352    {
    353         CCOUT(4) << "Reloading ..." << std::endl;
     353        orxout(verbose, context::input) << "InputManager: Reloading ..." << endl;
    354354
    355355        this->destroyDevices();
     
    357357
    358358        internalState_ &= ~Bad;
    359         CCOUT(4) << "Reloading complete." << std::endl;
     359        orxout(verbose, context::input) << "InputManager: Reloading complete." << endl;
    360360    }
    361361
     
    471471    void InputManager::calibrate()
    472472    {
    473         COUT(0) << "Move all joy stick axes fully in all directions." << std::endl
    474                 << "When done, put the axex in the middle position and press enter." << std::endl;
     473        orxout(message) << "Move all joy stick axes fully in all directions." << '\n'
     474                        << "When done, put the axex in the middle position and press enter." << endl;
    475475
    476476        BOOST_FOREACH(InputDevice* device, devices_)
     
    495495        this->clearBuffers();
    496496
    497         COUT(0) << "Calibration has been stored." << std::endl;
     497        orxout(message) << "Calibration has been stored." << endl;
    498498    }
    499499
     
    535535                    if (it->second->getPriority() == priority)
    536536                    {
    537                         COUT(2) << "Warning: Could not add an InputState with the same priority '"
    538                             << static_cast<int>(priority) << "' != 0." << std::endl;
     537                        orxout(internal_warning, context::input) << "Could not add an InputState with the same priority '"
     538                            << static_cast<int>(priority) << "' != 0." << endl;
    539539                        return 0;
    540540                    }
     
    548548        else
    549549        {
    550             COUT(2) << "Warning: Could not add an InputState with the same name '" << name << "'." << std::endl;
     550            orxout(internal_warning, context::input) << "Could not add an InputState with the same name '" << name << "'." << endl;
    551551            return 0;
    552552        }
     
    598598        if (name == "empty")
    599599        {
    600             COUT(2) << "InputManager: Leaving the empty state is not allowed!" << std::endl;
     600            orxout(internal_warning, context::input) << "InputManager: Leaving the empty state is not allowed!" << endl;
    601601            return false;
    602602        }
     
    623623        if (name == "empty")
    624624        {
    625             COUT(2) << "InputManager: Removing the empty state is not allowed!" << std::endl;
     625            orxout(internal_warning, context::input) << "InputManager: Removing the empty state is not allowed!" << endl;
    626626            return false;
    627627        }
     
    649649        if (name == "empty")
    650650        {
    651             COUT(2) << "InputManager: Changing the empty state is not allowed!" << std::endl;
     651            orxout(internal_warning, context::input) << "InputManager: Changing the empty state is not allowed!" << endl;
    652652            return false;
    653653        }
  • code/trunk/src/libraries/core/input/JoyStick.cc

    r6536 r8858  
    8080        }
    8181
    82         COUT(4) << "Created OIS joy stick with ID " << deviceName_ << std::endl;
     82        orxout(verbose, context::input) << "Created OIS joy stick with ID " << deviceName_ << endl;
    8383
    8484        // Load calibration
  • code/trunk/src/libraries/core/input/KeyBinder.cc

    r8366 r8858  
    3232#include <sstream>
    3333#include "util/Convert.h"
    34 #include "util/Debug.h"
     34#include "util/Output.h"
    3535#include "util/Exception.h"
    3636#include "core/ConfigValueIncludes.h"
     
    251251    void KeyBinder::loadBindings()
    252252    {
    253         COUT(3) << "KeyBinder: Loading key bindings..." << std::endl;
     253        orxout(internal_info, context::input) << "KeyBinder: Loading key bindings..." << endl;
    254254
    255255        this->configFile_ = new ConfigFile(this->filename_, !PathConfig::buildDirectoryRun());
     
    277277        }
    278278
    279         COUT(3) << "KeyBinder: Loading key bindings done." << std::endl;
     279        orxout(internal_info, context::input) << "KeyBinder: Loading key bindings done." << endl;
    280280    }
    281281
     
    294294        else
    295295        {
    296             COUT(2) << "Could not find key/button/axis with name '" << name << "'." << std::endl;
     296            orxout(internal_warning, context::input) << "Could not find key/button/axis with name '" << name << "'." << endl;
    297297            return false;
    298298        }
  • code/trunk/src/libraries/core/input/KeyBinderManager.cc

    r7284 r8858  
    2929#include "KeyBinderManager.h"
    3030
    31 #include "util/Debug.h"
     31#include "util/Output.h"
    3232#include "util/Exception.h"
    3333#include "util/ScopedSingletonManager.h"
     
    168168        if (!this->bBinding_)
    169169        {
    170             COUT(0) << "Press any button/key or move a mouse/joystick axis" << std::endl;
     170            orxout(message) << "Press any button/key or move a mouse/joystick axis" << endl;
    171171            KeyDetector::getInstance().setCallback(createFunctor(&KeyBinderManager::keybindKeyPressed, this));
    172172            InputManager::getInstance().enterState("detector");
     
    185185            if (keyName == "Keys.KeyEscape")
    186186            {
    187                 COUT(0) << "Keybinding aborted." << std::endl;
     187                orxout(message) << "Keybinding aborted." << endl;
    188188            }
    189189            else
    190190            {
    191                 COUT(0) << "Binding string \"" << command_ << "\" on key '" << keyName << "'" << std::endl;
     191                orxout(message) << "Binding string \"" << command_ << "\" on key '" << keyName << "'" << endl;
    192192                this->currentBinder_->setBinding(command_, keyName, bTemporary_);
    193193            }
Note: See TracChangeset for help on using the changeset viewer.