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/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        }
Note: See TracChangeset for help on using the changeset viewer.