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/orxonox/sound/AmbientSound.cc

    r8706 r8858  
    9494                this->setSource(path);
    9595            else
    96                 COUT(3) << "Sound: " << this->ambientSource_ << ": Not a valid name! Ambient sound will not change." << std::endl;
     96                orxout(internal_warning, context::sound) << this->ambientSource_ << ": Not a valid name! Ambient sound will not change." << endl;
    9797        }
    9898    }
  • code/trunk/src/orxonox/sound/BaseSound.cc

    r8729 r8858  
    9494            alSourcePlay(this->audioSource_);
    9595            if (int error = alGetError())
    96                 COUT(2) << "Sound: Error playing sound: " << SoundManager::getALErrorString(error) << std::endl;
     96                orxout(internal_error, context::sound) << "Error playing sound: " << SoundManager::getALErrorString(error) << endl;
    9797        }
    9898    }
     
    147147        alSource3f(this->audioSource_, AL_DIRECTION, 0, 0, 0);
    148148        if (ALint error = alGetError())
    149             COUT(2) << "Sound Warning: Setting source parameters to 0 failed: "
    150                     << SoundManager::getALErrorString(error) << std::endl;
     149            orxout(internal_warning, context::sound) << "Setting source parameters to 0 failed: "
     150                                                     << SoundManager::getALErrorString(error) << endl;
    151151        assert(this->soundBuffer_ != NULL);
    152152        alSourcei(this->audioSource_, AL_BUFFER, this->soundBuffer_->getBuffer());
    153153        if (ALuint error = alGetError())
    154             COUT(1) << "Sound Error: Could not set buffer \"" << this->source_ << "\": " << SoundManager::getALErrorString(error) << std::endl;
     154            orxout(internal_error, context::sound) << "Could not set buffer \"" << this->source_ << "\": " << SoundManager::getALErrorString(error) << endl;
    155155    }
    156156
     
    159159        this->volume_ = clamp(vol, 0.0f, 1.0f);
    160160        if (this->volume_ != vol)
    161             COUT(2) << "Sound warning: volume out of range, clamping value." << std::endl;
     161            orxout(internal_warning, context::sound) << "Volume out of range, clamping value." << endl;
    162162        this->updateVolume();
    163163    }
     
    170170            alSourcef(this->audioSource_, AL_GAIN, volume);
    171171            if (int error = alGetError())
    172                 COUT(2) << "Sound: Error setting volume to " << volume
    173                         << ": " << SoundManager::getALErrorString(error) << std::endl;
     172                orxout(internal_error, context::sound) << "Error setting volume to " << volume
     173                                                       << ": " << SoundManager::getALErrorString(error) << endl;
    174174        }
    175175    }
     
    186186        if (pitch > 2 || pitch < 0.5f)
    187187        {
    188             COUT(2) << "Sound warning: pitch out of range, cropping value." << std::endl;
     188            orxout(internal_warning, context::sound) << "Pitch out of range, cropping value." << endl;
    189189            pitch = pitch > 2.0f ? 2.0f : pitch;
    190190            pitch = pitch < 0.5f ? 0.5f : pitch;
     
    195195            alSourcef(this->audioSource_, AL_PITCH, pitch);
    196196            if (int error = alGetError())
    197                 COUT(2) << "Sound: Error setting pitch: " << SoundManager::getALErrorString(error) << std::endl;
     197                orxout(internal_error, context::sound) << "Error setting pitch: " << SoundManager::getALErrorString(error) << endl;
    198198        }
    199199    }
     
    240240            if (ALuint error = alGetError())
    241241            {
    242                 COUT(1) << "Sound Error: Could not set buffer \"" << source << "\": " << SoundManager::getALErrorString(error) << std::endl;
     242                orxout(internal_error, context::sound) << "Could not set buffer \"" << source << "\": " << SoundManager::getALErrorString(error) << endl;
    243243                return;
    244244            }
     
    248248            alSourcePlay(this->audioSource_);
    249249            if (int error = alGetError())
    250                 COUT(2) << "Sound: Error playing sound: " << SoundManager::getALErrorString(error) << std::endl;
     250                orxout(internal_error, context::sound) << "Error playing sound: " << SoundManager::getALErrorString(error) << endl;
    251251            if (this->isPaused())
    252252                alSourcePause(this->audioSource_);
  • code/trunk/src/orxonox/sound/SoundBuffer.cc

    r8351 r8858  
    5151        if (fileInfo == NULL)
    5252        {
    53             COUT(2) << "Sound: Warning: Sound file '" << filename << "' not found" << std::endl;
     53            orxout(internal_error, context::sound) << "Sound file '" << filename << "' not found" << endl;
    5454            return;
    5555        }
     
    144144        if (ret < 0)
    145145        {
    146             COUT(2) << "Sound: libvorbisfile: File does not seem to be an Ogg Vorbis bitstream" << std::endl;
     146            orxout(internal_error, context::sound) << "libvorbisfile: File does not seem to be an Ogg Vorbis bitstream" << endl;
    147147            ov_clear(&vf);
    148148            ThrowException(General, "Sound Error: Ogg file loader failed when opening the bitstream");
     
    160160            else if (ret < 0)
    161161            {
    162                 COUT(2) << "Sound: libvorbisfile: error reading the file" << std::endl;
     162                orxout(internal_error, context::sound) << "libvorbisfile: error reading the file" << endl;
    163163                ov_clear(&vf);
    164164                ThrowException(General, "Sound Error: Ogg file loader failed when decoding the file");
  • code/trunk/src/orxonox/sound/SoundManager.cc

    r8521 r8858  
    7171        RegisterRootObject(SoundManager);
    7272
     73        orxout(user_status) << "Loading sound" << endl;
     74
    7375        this->bDestructorCalled_ = false;
    7476         
     
    8991        std::string renderDevice;
    9092        SetConfigValue(renderDevice, std::string(device)).description("Sound device used for rendering");
    91         COUT(4) << "Sound: Available devices: ";
     93        orxout(verbose, context::sound) << "Sound: Available devices: ";
    9294        while (true)
    9395        {
    9496            this->deviceNames_.push_back(devices);
    95             COUT(4) << '"' << devices << "\", ";
     97            orxout(verbose, context::sound) << '"' << devices << "\", ";
    9698            devices += strlen(devices) + 1;
    9799            if (*devices == '\0')
    98100                break;
    99101        }
    100         COUT(4) << std::endl;
     102        orxout(verbose, context::sound) << endl;
    101103
    102104        // Open the selected device
    103         COUT(3) << "Sound: Opening device \"" << renderDevice << '\' << std::endl;
     105        orxout(internal_info, context::sound) << "Sound: Opening device \"" << renderDevice << '\' << endl;
    104106        this->device_ = alcOpenDevice(renderDevice.c_str());
    105107*/
     
    122124        // Get some information about the sound
    123125        if (const char* version = alGetString(AL_VERSION))
    124             COUT(4) << "Sound: --- OpenAL Version: " << version << std::endl;
     126            orxout(internal_info, context::sound) << "Sound: --- OpenAL Version: " << version << endl;
    125127        if (const char* vendor = alGetString(AL_VENDOR))
    126             COUT(4) << "Sound: --- OpenAL Vendor : " << vendor << std::endl;
     128            orxout(internal_info, context::sound) << "Sound: --- OpenAL Vendor : " << vendor << endl;
    127129        if (const char* types = alutGetMIMETypes(ALUT_LOADER_BUFFER))
    128             COUT(4) << "Sound: --- Supported MIME Types: " << types << std::endl;
     130            orxout(internal_info, context::sound) << "Sound: --- Supported MIME Types: " << types << endl;
    129131        else
    130             COUT(2) << "Sound Warning: MIME Type retrieval failed: " << alutGetErrorString(alutGetError()) << std::endl;
     132            orxout(internal_warning, context::sound) << "MIME Type retrieval failed: " << alutGetErrorString(alutGetError()) << endl;
    131133
    132134        this->mute_[SoundType::All]     = 1.0f;
     
    152154        resetPlaysSoundGuard.Dismiss();
    153155
    154         COUT(4) << "Sound: Initialisation complete" << std::endl;
     156        orxout(internal_status, context::sound) << "Sound: Initialisation complete" << endl;
    155157    }
    156158
     
    164166        // If there are still used buffers around, well, that's just very bad...
    165167        if (this->soundBuffers_.size() != this->effectsPool_.size())
    166             COUT(1) << "Sound Error: Some sound buffers are still in use but OpenAL is about to shut down. Fix this!" << std::endl;
     168            orxout(internal_error, context::sound) << "Some sound buffers are still in use but OpenAL is about to shut down. Fix this!" << endl;
    167169        // Empty buffer pool and buffer list
    168170        this->effectsPool_.clear();
     
    171173        // There should not be any sources in use anymore
    172174        if (!this->usedSoundSources_.empty())
    173             COUT(1) << "Sound Error: Some sound sources are still in use but OpenAL is about to shut down. Fix this!" << std::endl;
     175            orxout(internal_error, context::sound) << "Some sound sources are still in use but OpenAL is about to shut down. Fix this!" << endl;
    174176        while (!this->availableSoundSources_.empty())
    175177        {
     
    182184        // Relieve context to destroy it
    183185        if (!alcMakeContextCurrent(NULL))
    184             COUT(1) << "Sound Error: Could not unset ALC context" << std::endl;
     186            orxout(internal_error, context::sound) << "Could not unset ALC context" << endl;
    185187        alcDestroyContext(this->context_);
    186188        if (ALCenum error = alcGetError(this->device_))
    187189        {
    188190            if (error == AL_INVALID_OPERATION)
    189                 COUT(1) << "Sound Error: Could not destroy ALC context because it is the current one" << std::endl;
     191                orxout(internal_error, context::sound) << "Could not destroy ALC context because it is the current one" << endl;
    190192            else
    191                 COUT(1) << "Sound Error: Could not destroy ALC context because it is invalid" << std::endl;
     193                orxout(internal_error, context::sound) << "Could not destroy ALC context because it is invalid" << endl;
    192194        }
    193195#ifdef AL_VERSION_1_1
    194196        if (!alcCloseDevice(this->device_))
    195             COUT(1) << "Sound Error: Could not destroy ALC device. This might be because there are still buffers in use!" << std::endl;
     197            orxout(internal_error, context::sound) << "Could not destroy ALC device. This might be because there are still buffers in use!" << endl;
    196198#else
    197199        alcCloseDevice(this->device_);
    198200#endif
    199201        if (!alutExit())
    200             COUT(1) << "Sound Error: Closing ALUT failed: " << alutGetErrorString(alutGetError()) << std::endl;
     202            orxout(internal_error, context::sound) << "Closing ALUT failed: " << alutGetErrorString(alutGetError()) << endl;
    201203    }
    202204
     
    244246        if (crossFadeStep_ <= 0.0 || crossFadeStep_ >= 1.0 )
    245247        {
    246             COUT(2) << "Sound warning: fade step out of range, ignoring change." << std::endl;
     248            orxout(internal_warning, context::sound) << "Fade step out of range, ignoring change." << endl;
    247249            ResetConfigValue(crossFadeStep_);
    248250        }
     
    253255        float clampedVolume = clamp(this->volume_[type], 0.0f, 1.0f);
    254256        if (clampedVolume != this->volume_[type])
    255             COUT(2) << "Sound warning: Volume setting (" << type << ") out of range, clamping." << std::endl;
     257            orxout(internal_warning, context::sound) << "Volume setting (" << type << ") out of range, clamping." << endl;
    256258        this->updateVolume(type);
    257259    }
     
    321323        if (error == AL_INVALID_VALUE)
    322324            // @TODO: Follow this constantly appearing, nerve-racking warning
    323             COUT(2) << "Sound: OpenAL: Invalid listener position" << std::endl;
     325            orxout(internal_error, context::sound) << "OpenAL: Invalid listener position" << endl;
    324326    }
    325327
     
    335337        ALenum error = alGetError();
    336338        if (error == AL_INVALID_VALUE)
    337             COUT(2) << "Sound: OpenAL: Invalid listener orientation" << std::endl;
     339            orxout(internal_error, context::sound) << "OpenAL: Invalid listener orientation" << endl;
    338340    }
    339341
     
    346348                if (it->first == newAmbient)
    347349                {
    348                     COUT(2) << "Sound warning: Will not play an AmbientSound twice." << std::endl;
     350                    orxout(internal_warning, context::sound) << "Will not play an AmbientSound twice." << endl;
    349351                    return;
    350352                }
     
    520522            catch (const std::exception& ex)
    521523            {
    522                 COUT(1) << ex.what() << std::endl;
     524                orxout(internal_error, context::sound) << ex.what() << endl;
    523525                return buffer;
    524526            }
     
    614616            alDeleteSources(1, &this->availableSoundSources_.back());
    615617            if (alGetError())
    616                 COUT(1) << "Sound Error: Failed to delete a source --> lost forever" << std::endl;
     618                orxout(internal_error, context::sound) << "Failed to delete a source --> lost forever" << endl;
    617619            this->availableSoundSources_.pop_back();
    618620        }
  • code/trunk/src/orxonox/sound/SoundStreamer.cc

    r7163 r8858  
    5151        if (ret < 0)
    5252        {
    53             COUT(2) << "Sound: libvorbisfile: File does not seem to be an Ogg Vorbis bitstream" << std::endl;
     53            orxout(internal_error, context::sound) << "libvorbisfile: File does not seem to be an Ogg Vorbis bitstream" << endl;
    5454            ov_clear(&vf);
    5555            return;
     
    7777            else if (ret < 0)
    7878            {
    79                 COUT(2) << "Sound: libvorbisfile: error reading the file" << std::endl;
     79                orxout(internal_error, context::sound) << "libvorbisfile: error reading the file" << endl;
    8080                ov_clear(&vf);
    8181                return;
     
    9191            alGetSourcei(audioSource, AL_BUFFERS_PROCESSED, &processed);
    9292            if (ALint error = alGetError())
    93             COUT(2) << "Sound Warning: Couldn't get number of processed buffers: "
    94                     << SoundManager::getALErrorString(error) << std::endl;
     93            orxout(internal_warning, context::sound) << "Couldn't get number of processed buffers: "
     94                                                     << SoundManager::getALErrorString(error) << endl;
    9595
    9696            if(processed > 0)
     
    9999                alSourceUnqueueBuffers(audioSource, processed, buffers);
    100100                if (ALint error = alGetError())
    101                     COUT(2) << "Sound Warning: Couldn't unqueue buffers: "
    102                     << SoundManager::getALErrorString(error) << std::endl;
     101                    orxout(internal_warning, context::sound) << "Couldn't unqueue buffers: "
     102                                                             << SoundManager::getALErrorString(error) << endl;
    103103
    104104                for(int i = 0; i < processed; i++)
     
    111111                    else if (ret < 0)
    112112                    {
    113                         COUT(2) << "Sound: libvorbisfile: error reading the file" << std::endl;
     113                        orxout(internal_error, context::sound) << "libvorbisfile: error reading the file" << endl;
    114114                        ov_clear(&vf);
    115115                        return;
     
    121121                alSourceQueueBuffers(audioSource, processed, buffers);
    122122                if (ALint error = alGetError())
    123                     COUT(2) << "Sound Warning: Couldn't queue buffers: "
    124                     << SoundManager::getALErrorString(error) << std::endl;
     123                    orxout(internal_warning, context::sound) << "Couldn't queue buffers: "
     124                                                             << SoundManager::getALErrorString(error) << endl;
    125125            }
    126126        }
  • code/trunk/src/orxonox/sound/WorldSound.cc

    r8351 r8858  
    9494            ALenum error = alGetError();
    9595            if (error == AL_INVALID_VALUE)
    96                 COUT(2) << "Sound: OpenAL: Invalid sound position" << std::endl;
     96                orxout(internal_error, context::sound) << "OpenAL: Invalid sound position" << endl;
    9797
    9898            const Vector3& vel = this->getVelocity();
     
    100100            error = alGetError();
    101101            if (error == AL_INVALID_VALUE)
    102                 COUT(2) << "Sound: OpenAL: Invalid sound velocity" << std::endl;
     102                orxout(internal_error, context::sound) << "OpenAL: Invalid sound velocity" << endl;
    103103
    104104            const Vector3& direction = -this->getWorldOrientation().zAxis();
     
    106106            error = alGetError();
    107107            if (error == AL_INVALID_VALUE)
    108                 COUT(2) << "Sound: OpenAL: Invalid sound direction" << std::endl;
     108                orxout(internal_error, context::sound) << "OpenAL: Invalid sound direction" << endl;
    109109        }
    110110    }
Note: See TracChangeset for help on using the changeset viewer.