From 1452684d9e58c8e59c3d2bf85c837894b2feb6fe Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Tue, 14 Aug 2018 19:42:41 +0400 Subject: [PATCH 1/3] Use new logging system for components --- components/crashcatcher/crashcatcher.cpp | 11 +++-- components/debug/debuglog.hpp | 1 - components/esm/cellref.cpp | 6 +-- components/esm/loadcrea.cpp | 4 +- components/esm/loaddial.cpp | 4 +- components/esm/loadscpt.cpp | 12 ++--- components/esmterrain/storage.cpp | 3 +- components/files/configurationmanager.cpp | 9 ++-- components/files/multidircollection.cpp | 6 +-- components/fontloader/fontloader.cpp | 6 ++- components/interpreter/defines.cpp | 6 +-- components/myguiplatform/myguidatamanager.cpp | 4 +- components/myguiplatform/myguitexture.cpp | 3 +- components/nif/niffile.hpp | 5 +- components/nifbullet/bulletnifloader.cpp | 5 +- components/nifbullet/bulletnifloader.hpp | 6 +-- components/nifosg/nifloader.cpp | 48 +++++++++---------- components/nifosg/particle.cpp | 3 +- components/resource/imagemanager.cpp | 9 ++-- components/resource/scenemanager.cpp | 11 +++-- components/sceneutil/attach.cpp | 3 +- components/sceneutil/riggeometry.cpp | 11 +++-- components/sceneutil/skeleton.cpp | 5 +- components/sceneutil/unrefqueue.cpp | 4 +- components/sceneutil/workqueue.cpp | 4 +- components/sdlutil/sdlcursormanager.cpp | 8 ++-- components/sdlutil/sdlinputwrapper.cpp | 6 +-- components/sdlutil/sdlvideowrapper.cpp | 4 +- components/settings/settings.cpp | 26 +++++----- components/shader/shadermanager.cpp | 16 ++++--- components/shader/shadervisitor.cpp | 3 +- components/to_utf8/to_utf8.cpp | 7 ++- components/vfs/filesystemarchive.cpp | 6 +-- components/vfs/registerarchives.cpp | 9 ++-- components/widgets/imagebutton.cpp | 4 +- 35 files changed, 144 insertions(+), 134 deletions(-) diff --git a/components/crashcatcher/crashcatcher.cpp b/components/crashcatcher/crashcatcher.cpp index f7b8717a6..04b239a7f 100644 --- a/components/crashcatcher/crashcatcher.cpp +++ b/components/crashcatcher/crashcatcher.cpp @@ -14,7 +14,7 @@ #include #include -#include +#include #include @@ -185,7 +185,7 @@ static void gdb_info(pid_t pid) if (close(fd) == 0) remove(respfile); else - std::cerr << "Warning: can not close and remove file '" << respfile << "': " << std::strerror(errno) << std::endl; + Log(Debug::Warning) << "Warning: can not close and remove file '" << respfile << "': " << std::strerror(errno); } printf("!!! Could not create gdb command file\n"); } @@ -517,8 +517,9 @@ void crashCatcherInstall(int argc, char **argv, const std::string &crashLogPath) int s[5] = { SIGSEGV, SIGILL, SIGFPE, SIGBUS, SIGABRT }; if (crashCatcherInstallHandlers(argc, argv, 5, s, crashLogPath.c_str(), NULL) == -1) { - std::cerr << "Installing crash handler failed" << std::endl; - } else - std::cout << "Crash handler installed" << std::endl; + Log(Debug::Warning) << "Installing crash handler failed"; + } + else + Log(Debug::Info) << "Crash handler installed"; } } diff --git a/components/debug/debuglog.hpp b/components/debug/debuglog.hpp index bfd7d1196..1ea18aa9b 100644 --- a/components/debug/debuglog.hpp +++ b/components/debug/debuglog.hpp @@ -2,7 +2,6 @@ #define DEBUG_LOG_H #include -#include #include namespace Debug diff --git a/components/esm/cellref.cpp b/components/esm/cellref.cpp index 1f7c2b964..4b9c6b073 100644 --- a/components/esm/cellref.cpp +++ b/components/esm/cellref.cpp @@ -1,6 +1,6 @@ #include "cellref.hpp" -#include +#include #include "esmreader.hpp" #include "esmwriter.hpp" @@ -48,9 +48,7 @@ void ESM::CellRef::loadId (ESMReader& esm, bool wideRefNum) mRefID = esm.getHNOString ("NAME"); if (mRefID.empty()) { - std::ios::fmtflags f(std::cerr.flags()); - std::cerr << "Warning: got CellRef with empty RefId in " << esm.getName() << " 0x" << std::hex << esm.getFileOffset() << std::endl; - std::cerr.flags(f); + Log(Debug::Warning) << "Warning: got CellRef with empty RefId in " << esm.getName() << " 0x" << std::hex << esm.getFileOffset(); } } diff --git a/components/esm/loadcrea.cpp b/components/esm/loadcrea.cpp index ddd49f8df..83315a5b8 100644 --- a/components/esm/loadcrea.cpp +++ b/components/esm/loadcrea.cpp @@ -1,6 +1,6 @@ #include "loadcrea.hpp" -#include +#include #include "esmreader.hpp" #include "esmwriter.hpp" @@ -89,7 +89,7 @@ namespace ESM { // seems to occur only in .ESS files, unsure of purpose int index; esm.getHT(index); - std::cerr << "Creature::load: Unhandled INDX " << index << std::endl; + Log(Debug::Warning) << "Creature::load: Unhandled INDX " << index; break; default: esm.fail("Unknown subrecord"); diff --git a/components/esm/loaddial.cpp b/components/esm/loaddial.cpp index 9ef3d3964..d7e0a6ee1 100644 --- a/components/esm/loaddial.cpp +++ b/components/esm/loaddial.cpp @@ -1,6 +1,6 @@ #include "loaddial.hpp" -#include +#include #include "esmreader.hpp" #include "esmwriter.hpp" @@ -128,7 +128,7 @@ namespace ESM return; } - std::cerr << "Warning: Failed to insert info " << info.mId << std::endl; + Log(Debug::Warning) << "Warning: Failed to insert info " << info.mId; } void Dialogue::clearDeletedInfos() diff --git a/components/esm/loadscpt.cpp b/components/esm/loadscpt.cpp index 19246c4c4..474c2b423 100644 --- a/components/esm/loadscpt.cpp +++ b/components/esm/loadscpt.cpp @@ -1,11 +1,11 @@ #include "loadscpt.hpp" +#include + #include "esmreader.hpp" #include "esmwriter.hpp" #include "defs.hpp" -#include - namespace ESM { unsigned int Script::sRecordId = REC_SCPT; @@ -45,12 +45,12 @@ namespace ESM // an exeption, just log an error and continue. std::stringstream ss; - ss << "ESM Error: " << "String table overflow"; + ss << "String table overflow"; ss << "\n File: " << esm.getName(); ss << "\n Record: " << esm.getContext().recName.toString(); ss << "\n Subrecord: " << "SCVR"; ss << "\n Offset: 0x" << std::hex << esm.getFileOffset(); - std::cerr << ss.str() << std::endl; + Log(Debug::Verbose) << ss.str(); break; } @@ -91,10 +91,10 @@ namespace ESM if (subSize != static_cast(mData.mScriptDataSize)) { std::stringstream ss; - ss << "ESM Warning: Script data size defined in SCHD subrecord does not match size of SCDT subrecord"; + ss << "Script data size defined in SCHD subrecord does not match size of SCDT subrecord"; ss << "\n File: " << esm.getName(); ss << "\n Offset: 0x" << std::hex << esm.getFileOffset(); - std::cerr << ss.str() << std::endl; + Log(Debug::Verbose) << ss.str(); } mScriptData.resize(subSize); diff --git a/components/esmterrain/storage.cpp b/components/esmterrain/storage.cpp index 0f5b17502..f77e66276 100644 --- a/components/esmterrain/storage.cpp +++ b/components/esmterrain/storage.cpp @@ -10,6 +10,7 @@ #include +#include #include #include @@ -378,7 +379,7 @@ namespace ESMTerrain const ESM::LandTexture* ltex = getLandTexture(id.first-1, id.second); if (!ltex) { - std::cerr << "Warning: Unable to find land texture index " << id.first-1 << " in plugin " << id.second << ", using default texture instead" << std::endl; + Log(Debug::Warning) << "Warning: Unable to find land texture index " << id.first-1 << " in plugin " << id.second << ", using default texture instead"; return defaultTexture; } diff --git a/components/files/configurationmanager.cpp b/components/files/configurationmanager.cpp index 7c3956a29..333ec5ced 100644 --- a/components/files/configurationmanager.cpp +++ b/components/files/configurationmanager.cpp @@ -1,7 +1,6 @@ #include "configurationmanager.hpp" -#include - +#include #include #include @@ -134,7 +133,7 @@ bool ConfigurationManager::loadConfig(const boost::filesystem::path& path, if (boost::filesystem::is_regular_file(cfgFile)) { if (!mSilent) - std::cout << "Loading config file: " << cfgFile.string() << "... "; + Log(Debug::Info) << "Loading config file: " << cfgFile.string() << "... "; boost::filesystem::ifstream configFileStreamUnfiltered(cfgFile); boost::iostreams::filtering_istream configFileStream; @@ -146,13 +145,13 @@ bool ConfigurationManager::loadConfig(const boost::filesystem::path& path, configFileStream, description, true), variables); if (!mSilent) - std::cout << "done." << std::endl; + Log(Debug::Info) << "done."; return true; } else { if (!mSilent) - std::cout << "failed." << std::endl; + Log(Debug::Info) << "failed."; return false; } } diff --git a/components/files/multidircollection.cpp b/components/files/multidircollection.cpp index 93db6834d..98e25fcc8 100644 --- a/components/files/multidircollection.cpp +++ b/components/files/multidircollection.cpp @@ -1,9 +1,9 @@ #include "multidircollection.hpp" -#include - #include +#include + namespace Files { struct NameEqual @@ -46,7 +46,7 @@ namespace Files { if (!boost::filesystem::is_directory(*iter)) { - std::cout << "Skipping invalid directory: " << (*iter).string() << std::endl; + Log(Debug::Info) << "Skipping invalid directory: " << (*iter).string(); continue; } diff --git a/components/fontloader/fontloader.cpp b/components/fontloader/fontloader.cpp index 080739bc1..790df7fa8 100644 --- a/components/fontloader/fontloader.cpp +++ b/components/fontloader/fontloader.cpp @@ -14,6 +14,8 @@ #include #include +#include + #include #include @@ -281,7 +283,7 @@ namespace Gui assert (image->isDataContiguous()); memcpy(image->data(), &textureData[0], textureData.size()); - std::cout << "Writing " << resourceName + ".png" << std::endl; + Log(Debug::Info) << "Writing " << resourceName + ".png"; osgDB::writeImageFile(*image, resourceName + ".png"); } @@ -461,7 +463,7 @@ namespace Gui if (exportToFile) { - std::cout << "Writing " << resourceName + ".xml" << std::endl; + Log(Debug::Info) << "Writing " << resourceName + ".xml"; xmlDocument.createDeclaration(); xmlDocument.save(resourceName + ".xml"); } diff --git a/components/interpreter/defines.cpp b/components/interpreter/defines.cpp index 515c6c7d5..3c6226d9c 100644 --- a/components/interpreter/defines.cpp +++ b/components/interpreter/defines.cpp @@ -3,8 +3,8 @@ #include #include #include -#include +#include #include namespace Interpreter{ @@ -191,8 +191,8 @@ namespace Interpreter{ } catch (std::exception& e) { - std::cerr << "Error: Failed to replace escape character, with the following error: " << e.what() << std::endl; - std::cerr << "Full text below: " << std::endl << text << std::endl; + Log(Debug::Error) << "Error: Failed to replace escape character, with the following error: " << e.what(); + Log(Debug::Error) << "Full text below:\n" << text; } // Not found, or error diff --git a/components/myguiplatform/myguidatamanager.cpp b/components/myguiplatform/myguidatamanager.cpp index 485a87ba7..ddd7ca342 100644 --- a/components/myguiplatform/myguidatamanager.cpp +++ b/components/myguiplatform/myguidatamanager.cpp @@ -5,7 +5,7 @@ #include #include -#include +#include namespace osgMyGUI { @@ -23,7 +23,7 @@ MyGUI::IDataStream *DataManager::getData(const std::string &name) stream->open(fullpath, std::ios::binary); if (stream->fail()) { - std::cerr << "DataManager::getData: Failed to open '" << name << "'" << std::endl; + Log(Debug::Error) << "DataManager::getData: Failed to open '" << name << "'"; return NULL; } return new MyGUI::DataFileStream(stream.release()); diff --git a/components/myguiplatform/myguitexture.cpp b/components/myguiplatform/myguitexture.cpp index a3b70eac9..6c53a9699 100644 --- a/components/myguiplatform/myguitexture.cpp +++ b/components/myguiplatform/myguitexture.cpp @@ -5,6 +5,7 @@ #include +#include #include namespace osgMyGUI @@ -112,7 +113,7 @@ namespace osgMyGUI void OSGTexture::saveToFile(const std::string &fname) { - std::cerr << "Would save image to file " << fname << std::endl; + Log(Debug::Warning) << "Would save image to file " << fname; } int OSGTexture::getWidth() diff --git a/components/nif/niffile.hpp b/components/nif/niffile.hpp index cab2e9880..0893db72f 100644 --- a/components/nif/niffile.hpp +++ b/components/nif/niffile.hpp @@ -5,8 +5,8 @@ #include #include -#include +#include #include #include "record.hpp" @@ -80,8 +80,7 @@ public: /// Used when something goes wrong, but not catastrophically so void warn(const std::string &msg) const override { - std::cerr << " NIFFile Warning: " << msg < #include +#include + #include #include @@ -18,7 +20,6 @@ #include #include - namespace { @@ -203,7 +204,7 @@ void BulletNifLoader::handleNode(const std::string& fileName, const Nif::Node *n isCollisionNode = isCollisionNode || (node->recType == Nif::RC_RootCollisionNode); if (node->recType == Nif::RC_RootCollisionNode && autogenerated) - std::cerr << "Found RootCollisionNode attached to non-root node in " << fileName << ". Treat it as a common NiTriShape." << std::endl; + Log(Debug::Info) << "Found RootCollisionNode attached to non-root node in " << fileName << ". Treat it as a common NiTriShape."; // Don't collide with AvoidNode shapes if(node->recType == Nif::RC_AvoidNode) diff --git a/components/nifbullet/bulletnifloader.hpp b/components/nifbullet/bulletnifloader.hpp index 44134fd23..f970b7f3e 100644 --- a/components/nifbullet/bulletnifloader.hpp +++ b/components/nifbullet/bulletnifloader.hpp @@ -4,7 +4,6 @@ #include #include #include -#include #include #include @@ -12,6 +11,7 @@ #include #include +#include #include #include @@ -41,12 +41,12 @@ public: void warn(const std::string &msg) { - std::cerr << "NIFLoader: Warn:" << msg << "\n"; + Log(Debug::Warning) << "NIFLoader: Warn:" << msg; } void fail(const std::string &msg) { - std::cerr << "NIFLoader: Fail: "<< msg << std::endl; + Log(Debug::Error) << "NIFLoader: Fail: "<< msg; abort(); } diff --git a/components/nifosg/nifloader.cpp b/components/nifosg/nifloader.cpp index 5857a3987..3198e995c 100644 --- a/components/nifosg/nifloader.cpp +++ b/components/nifosg/nifloader.cpp @@ -243,7 +243,7 @@ namespace NifOsg callback->setFunction(std::shared_ptr(new NifOsg::ControllerFunction(key))); if (target.mKeyframeControllers.find(strdata->string) != target.mKeyframeControllers.end()) - std::cerr << "Warning: controller " << strdata->string << " present more than once in " << nif->getFilename() << ", ignoring later version" << std::endl; + Log(Debug::Verbose) << "Controller " << strdata->string << " present more than once in " << nif->getFilename() << ", ignoring later version"; else target.mKeyframeControllers[strdata->string] = callback; } @@ -357,20 +357,20 @@ namespace NifOsg { if (nifNode->recType != Nif::RC_NiTextureEffect) { - std::cerr << "Unhandled effect " << nifNode->recName << " in " << mFilename << std::endl; + Log(Debug::Info) << "Unhandled effect " << nifNode->recName << " in " << mFilename; return; } const Nif::NiTextureEffect* textureEffect = static_cast(nifNode); if (textureEffect->textureType != Nif::NiTextureEffect::Environment_Map) { - std::cerr << "Unhandled NiTextureEffect type " << textureEffect->textureType << " in " << mFilename << std::endl; + Log(Debug::Info) << "Unhandled NiTextureEffect type " << textureEffect->textureType << " in " << mFilename; return; } if (textureEffect->texture.empty()) { - std::cerr << "NiTextureEffect missing source texture in " << mFilename << std::endl; + Log(Debug::Info) << "NiTextureEffect missing source texture in " << mFilename; return; } @@ -387,7 +387,7 @@ namespace NifOsg texGen->setMode(osg::TexGen::SPHERE_MAP); break; default: - std::cerr << "Unhandled NiTextureEffect coordGenType " << textureEffect->coordGenType << " in " << mFilename << std::endl; + Log(Debug::Info) << "Unhandled NiTextureEffect coordGenType " << textureEffect->coordGenType << " in " << mFilename; return; } @@ -638,7 +638,7 @@ namespace NifOsg else if(ctrl->recType == Nif::RC_NiGeomMorpherController) {} // handled in handleTriShape else - std::cerr << "Unhandled controller " << ctrl->recName << " on node " << nifNode->recIndex << " in " << mFilename << std::endl; + Log(Debug::Info) << "Unhandled controller " << ctrl->recName << " on node " << nifNode->recIndex << " in " << mFilename; } } @@ -664,7 +664,7 @@ namespace NifOsg handleVisController(static_cast(ctrl.getPtr()), transformNode, animflags); } else - std::cerr << "Unhandled controller " << ctrl->recName << " on node " << nifNode->recIndex << " in " << mFilename << std::endl; + Log(Debug::Info) << "Unhandled controller " << ctrl->recName << " on node " << nifNode->recIndex << " in " << mFilename; } } @@ -696,7 +696,7 @@ namespace NifOsg composite->addController(osgctrl); } else - std::cerr << "Unexpected material controller " << ctrl->recType << " in " << mFilename << std::endl; + Log(Debug::Info) << "Unexpected material controller " << ctrl->recType << " in " << mFilename; } } @@ -736,7 +736,7 @@ namespace NifOsg composite->addController(callback); } else - std::cerr << "Unexpected texture controller " << ctrl->recName << " in " << mFilename << std::endl; + Log(Debug::Info) << "Unexpected texture controller " << ctrl->recName << " in " << mFilename; } } @@ -769,7 +769,7 @@ namespace NifOsg // unused } else - std::cerr << "Unhandled particle modifier " << affectors->recName << " in " << mFilename << std::endl; + Log(Debug::Info) << "Unhandled particle modifier " << affectors->recName << " in " << mFilename; } for (; !colliders.empty(); colliders = colliders->extra) { @@ -784,7 +784,7 @@ namespace NifOsg program->addOperator(new SphericalCollider(sphericalcollider)); } else - std::cerr << "Unhandled particle collider " << colliders->recName << " in " << mFilename << std::endl; + Log(Debug::Info) << "Unhandled particle collider " << colliders->recName << " in " << mFilename; } } @@ -881,11 +881,11 @@ namespace NifOsg if(ctrl->recType == Nif::RC_NiParticleSystemController || ctrl->recType == Nif::RC_NiBSPArrayController) partctrl = static_cast(ctrl.getPtr()); else - std::cerr << "Unhandled controller " << ctrl->recName << " on node " << nifNode->recIndex << " in " << mFilename << std::endl; + Log(Debug::Info) << "Unhandled controller " << ctrl->recName << " on node " << nifNode->recIndex << " in " << mFilename; } if (!partctrl) { - std::cerr << "No particle controller found in " << mFilename << std::endl; + Log(Debug::Info) << "No particle controller found in " << mFilename; return; } @@ -925,7 +925,7 @@ namespace NifOsg rootNode->accept(find); if (!find.mFound) { - std::cerr << "can't find emitter node, wrong node order? in " << mFilename << std::endl; + Log(Debug::Info) << "can't find emitter node, wrong node order? in " << mFilename; return; } osg::Group* emitterNode = find.mFound; @@ -1121,7 +1121,7 @@ namespace NifOsg case 9: return osg::BlendFunc::ONE_MINUS_DST_ALPHA; case 10: return osg::BlendFunc::SRC_ALPHA_SATURATE; default: - std::cerr<< "Unexpected blend mode: "<< mode << " in " << mFilename << std::endl; + Log(Debug::Info) << "Unexpected blend mode: "<< mode << " in " << mFilename; return osg::BlendFunc::SRC_ALPHA; } } @@ -1139,7 +1139,7 @@ namespace NifOsg case 6: return osg::AlphaFunc::GEQUAL; case 7: return osg::AlphaFunc::NEVER; default: - std::cerr << "Unexpected blend mode: " << mode << " in " << mFilename << std::endl; + Log(Debug::Info) << "Unexpected blend mode: " << mode << " in " << mFilename; return osg::AlphaFunc::LEQUAL; } } @@ -1157,7 +1157,7 @@ namespace NifOsg case 6: return osg::Stencil::GEQUAL; case 7: return osg::Stencil::NEVER; // NifSkope says this is GL_ALWAYS, but in MW it's GL_NEVER default: - std::cerr << "Unexpected stencil function: " << func << " in " << mFilename << std::endl; + Log(Debug::Info) << "Unexpected stencil function: " << func << " in " << mFilename; return osg::Stencil::NEVER; } } @@ -1173,7 +1173,7 @@ namespace NifOsg case 4: return osg::Stencil::DECR; case 5: return osg::Stencil::INVERT; default: - std::cerr << "Unexpected stencil operation: " << op << " in " << mFilename << std::endl; + Log(Debug::Info) << "Unexpected stencil operation: " << op << " in " << mFilename; return osg::Stencil::KEEP; } } @@ -1192,7 +1192,7 @@ namespace NifOsg pixelformat = GL_RGBA; break; default: - std::cerr << "Unhandled internal pixel format " << pixelData->fmt << " in " << mFilename << std::endl; + Log(Debug::Info) << "Unhandled internal pixel format " << pixelData->fmt << " in " << mFilename; return NULL; } @@ -1210,7 +1210,7 @@ namespace NifOsg size_t mipSize = mip.height * mip.width * pixelData->bpp / 8; if (mipSize + mip.dataOffset > pixelData->data.size()) { - std::cerr << "Warning: Internal texture's mipmap data out of bounds, ignoring texture" << std::endl; + Log(Debug::Info) << "Internal texture's mipmap data out of bounds, ignoring texture"; return NULL; } @@ -1225,7 +1225,7 @@ namespace NifOsg if (width <= 0 || height <= 0) { - std::cerr << "Warning: Internal Texture Width and height must be non zero, ignoring texture" << std::endl; + Log(Debug::Info) << "Internal Texture Width and height must be non zero, ignoring texture"; return NULL; } @@ -1267,12 +1267,12 @@ namespace NifOsg { // Not used by the vanilla engine. MCP (Morrowind Code Patch) adds an option to use Gloss maps: // "- Gloss map fix. Morrowind removed gloss map entries from model files after loading them. This stops Morrowind from removing them." - //std::cerr << "NiTexturingProperty::GlossTexture in " << mFilename << " not currently used." << std::endl; + // Log(Debug::Info) << "NiTexturingProperty::GlossTexture in " << mFilename << " not currently used."; continue; } default: { - std::cerr << "Warning: unhandled texture stage " << i << " in " << mFilename << std::endl; + Log(Debug::Info) << "Unhandled texture stage " << i << " in " << mFilename; continue; } } @@ -1478,7 +1478,7 @@ namespace NifOsg break; } default: - std::cerr << "Unhandled " << property->recName << " in " << mFilename << std::endl; + Log(Debug::Info) << "Unhandled " << property->recName << " in " << mFilename; break; } } diff --git a/components/nifosg/particle.cpp b/components/nifosg/particle.cpp index 62360b9d6..03e836a0f 100644 --- a/components/nifosg/particle.cpp +++ b/components/nifosg/particle.cpp @@ -5,6 +5,7 @@ #include #include +#include #include #include #include @@ -284,7 +285,7 @@ void Emitter::emitParticles(double dt) if (!visitor.mFound) { - std::cerr << "Error: Can't find emitter node" << randomRecIndex << std::endl; + Log(Debug::Info) << "Can't find emitter node" << randomRecIndex; return; } diff --git a/components/resource/imagemanager.cpp b/components/resource/imagemanager.cpp index 000a833cf..c1d71ee00 100644 --- a/components/resource/imagemanager.cpp +++ b/components/resource/imagemanager.cpp @@ -3,6 +3,7 @@ #include #include +#include #include #include "objectcache.hpp" @@ -97,7 +98,7 @@ namespace Resource } catch (std::exception& e) { - std::cerr << "Failed to open image: " << e.what() << std::endl; + Log(Debug::Error) << "Failed to open image: " << e.what(); mCache->addEntryToObjectCache(normalized, mWarningImage); return mWarningImage; } @@ -109,7 +110,7 @@ namespace Resource osgDB::ReaderWriter* reader = osgDB::Registry::instance()->getReaderWriterForExtension(ext); if (!reader) { - std::cerr << "Error loading " << filename << ": no readerwriter for '" << ext << "' found" << std::endl; + Log(Debug::Error) << "Error loading " << filename << ": no readerwriter for '" << ext << "' found"; mCache->addEntryToObjectCache(normalized, mWarningImage); return mWarningImage; } @@ -117,7 +118,7 @@ namespace Resource osgDB::ReaderWriter::ReadResult result = reader->readImage(*stream, mOptions); if (!result.success()) { - std::cerr << "Error loading " << filename << ": " << result.message() << " code " << result.status() << std::endl; + Log(Debug::Error) << "Error loading " << filename << ": " << result.message() << " code " << result.status(); mCache->addEntryToObjectCache(normalized, mWarningImage); return mWarningImage; } @@ -130,7 +131,7 @@ namespace Resource static bool uncompress = (getenv("OPENMW_DECOMPRESS_TEXTURES") != 0); if (!uncompress) { - std::cerr << "Error loading " << filename << ": no S3TC texture compression support installed" << std::endl; + Log(Debug::Error) << "Error loading " << filename << ": no S3TC texture compression support installed"; mCache->addEntryToObjectCache(normalized, mWarningImage); return mWarningImage; } diff --git a/components/resource/scenemanager.cpp b/components/resource/scenemanager.cpp index db8d99ab4..8edb3d765 100644 --- a/components/resource/scenemanager.cpp +++ b/components/resource/scenemanager.cpp @@ -1,6 +1,5 @@ #include "scenemanager.hpp" -#include #include #include @@ -13,6 +12,8 @@ #include #include +#include + #include #include @@ -501,7 +502,7 @@ namespace Resource normalized = "meshes/marker_error." + std::string(sMeshTypes[i]); if (mVFS->exists(normalized)) { - std::cerr << "Failed to load '" << name << "': " << e.what() << ", using marker_error." << sMeshTypes[i] << " instead" << std::endl; + Log(Debug::Error) << "Failed to load '" << name << "': " << e.what() << ", using marker_error." << sMeshTypes[i] << " instead"; Files::IStreamPtr file = mVFS->get(normalized); loaded = load(file, normalized, mImageManager, mNifFileManager); break; @@ -658,12 +659,12 @@ namespace Resource if(magfilter == "nearest") mag = osg::Texture::NEAREST; else if(magfilter != "linear") - std::cerr<< "Warning: Invalid texture mag filter: "< #include +#include #include #include @@ -63,7 +64,7 @@ namespace SceneUtil { osg::ref_ptr node = *it; if (node->getNumParents() > 1) - std::cerr << "Error CopyRigVisitor: node has multiple parents" << std::endl; + Log(Debug::Error) << "Error CopyRigVisitor: node has multiple parents"; while (node->getNumParents()) node->getParent(0)->removeChild(node); diff --git a/components/sceneutil/riggeometry.cpp b/components/sceneutil/riggeometry.cpp index 7f148cf5e..ee30f1c85 100644 --- a/components/sceneutil/riggeometry.cpp +++ b/components/sceneutil/riggeometry.cpp @@ -1,9 +1,10 @@ #include "riggeometry.hpp" #include -#include #include +#include + #include "skeleton.hpp" #include "util.hpp" @@ -96,13 +97,13 @@ bool RigGeometry::initFromParentSkeleton(osg::NodeVisitor* nv) if (!mSkeleton) { - std::cerr << "Error: A RigGeometry did not find its parent skeleton" << std::endl; + Log(Debug::Error) << "Error: A RigGeometry did not find its parent skeleton"; return false; } if (!mInfluenceMap) { - std::cerr << "Error: No InfluenceMap set on RigGeometry" << std::endl; + Log(Debug::Error) << "Error: No InfluenceMap set on RigGeometry"; return false; } @@ -113,7 +114,7 @@ bool RigGeometry::initFromParentSkeleton(osg::NodeVisitor* nv) Bone* bone = mSkeleton->getBone(it->first); if (!bone) { - std::cerr << "Error: RigGeometry did not find bone " << it->first << std::endl; + Log(Debug::Error) << "Error: RigGeometry did not find bone " << it->first ; continue; } @@ -166,7 +167,7 @@ void RigGeometry::cull(osg::NodeVisitor* nv) { if (!mSkeleton) { - std::cerr << "Error: RigGeometry rendering with no skeleton, should have been initialized by UpdateVisitor" << std::endl; + Log(Debug::Error) << "Error: RigGeometry rendering with no skeleton, should have been initialized by UpdateVisitor"; // try to recover anyway, though rendering is likely to be incorrect. if (!initFromParentSkeleton(nv)) return; diff --git a/components/sceneutil/skeleton.cpp b/components/sceneutil/skeleton.cpp index 94ae1f234..58ed9a27c 100644 --- a/components/sceneutil/skeleton.cpp +++ b/components/sceneutil/skeleton.cpp @@ -3,10 +3,9 @@ #include #include +#include #include -#include - namespace SceneUtil { @@ -183,7 +182,7 @@ void Bone::update(const osg::Matrixf* parentMatrixInSkeletonSpace) { if (!mNode) { - std::cerr << "Error: Bone without node " << std::endl; + Log(Debug::Error) << "Error: Bone without node"; return; } if (parentMatrixInSkeletonSpace) diff --git a/components/sceneutil/unrefqueue.cpp b/components/sceneutil/unrefqueue.cpp index 7e5646ecb..42ea31133 100644 --- a/components/sceneutil/unrefqueue.cpp +++ b/components/sceneutil/unrefqueue.cpp @@ -3,8 +3,8 @@ #include //#include -//#include +//#include #include namespace SceneUtil @@ -20,7 +20,7 @@ namespace SceneUtil //osg::Timer timer; //size_t objcount = mObjects.size(); mObjects.clear(); - //std::cout << "cleared " << objcount << " objects in " << timer.time_m() << std::endl; + //Log(Debug::Verbose) << "cleared " << objcount << " objects in " << timer.time_m(); } }; diff --git a/components/sceneutil/workqueue.cpp b/components/sceneutil/workqueue.cpp index 2cd1ec806..37e8563e1 100644 --- a/components/sceneutil/workqueue.cpp +++ b/components/sceneutil/workqueue.cpp @@ -1,6 +1,6 @@ #include "workqueue.hpp" -#include +#include namespace SceneUtil { @@ -71,7 +71,7 @@ void WorkQueue::addWorkItem(osg::ref_ptr item, bool front) { if (item->isDone()) { - std::cerr << "Error: trying to add a work item that is already completed" << std::endl; + Log(Debug::Error) << "Error: trying to add a work item that is already completed"; return; } diff --git a/components/sdlutil/sdlcursormanager.cpp b/components/sdlutil/sdlcursormanager.cpp index 1747c9b94..1560b74b3 100644 --- a/components/sdlutil/sdlcursormanager.cpp +++ b/components/sdlutil/sdlcursormanager.cpp @@ -17,6 +17,8 @@ #include #include +#include + #include "imagetosurface.hpp" #if defined(OSG_LIBRARY_STATIC) && !defined(ANDROID) @@ -63,7 +65,7 @@ namespace CursorDecompression if (!_gc) { - std::cerr << "Failed to create pbuffer, failing back to normal graphics window." << std::endl; + Log(Debug::Warning) << "Failed to create pbuffer, failing back to normal graphics window."; traits->pbuffer = false; _gc = osg::GraphicsContext::createGraphicsContext(traits.get()); @@ -283,8 +285,8 @@ namespace SDLUtil mCursorMap.insert(CursorMap::value_type(std::string(name), curs)); } catch (std::exception& e) { - std::cerr << e.what() << std::endl; - std::cerr <<"Using default cursor."< +#include #include @@ -160,9 +160,7 @@ InputWrapper::InputWrapper(SDL_Window* window, osg::ref_ptr v break; default: - std::ios::fmtflags f(std::cerr.flags()); - std::cerr << "Unhandled SDL event of type 0x" << std::hex << evt.type << std::endl; - std::cerr.flags(f); + Log(Debug::Info) << "Unhandled SDL event of type 0x" << std::hex << evt.type; break; } } diff --git a/components/sdlutil/sdlvideowrapper.cpp b/components/sdlutil/sdlvideowrapper.cpp index dd89d1072..c2963be86 100644 --- a/components/sdlutil/sdlvideowrapper.cpp +++ b/components/sdlutil/sdlvideowrapper.cpp @@ -1,6 +1,6 @@ #include "sdlvideowrapper.hpp" -#include +#include #include @@ -65,7 +65,7 @@ namespace SDLUtil red[i] = green[i] = blue[i] = static_cast(value); } if (SDL_SetWindowGammaRamp(mWindow, red, green, blue) < 0) - std::cout << "Couldn't set gamma: " << SDL_GetError() << std::endl; + Log(Debug::Warning) << "Couldn't set gamma: " << SDL_GetError(); } void VideoWrapper::setVideoMode(int width, int height, bool fullscreen, bool windowBorder) diff --git a/components/settings/settings.cpp b/components/settings/settings.cpp index 15a222d31..66e5dfc04 100644 --- a/components/settings/settings.cpp +++ b/components/settings/settings.cpp @@ -1,8 +1,8 @@ #include "settings.hpp" #include -#include +#include #include #include @@ -69,7 +69,7 @@ public: mFile = file; boost::filesystem::ifstream stream; stream.open(boost::filesystem::path(file)); - std::cout << "Loading settings file: " << file << std::endl; + Log(Debug::Info) << "Loading settings file: " << file; std::string currentCategory; mLine = 0; while (!stream.eof() && !stream.fail()) @@ -186,8 +186,8 @@ public: // Ensure that all options in the current category have been written. for (CategorySettingStatusMap::iterator mit = written.begin(); mit != written.end(); ++mit) { if (mit->second == false && mit->first.first == currentCategory) { - std::cout << "Added new setting: [" << currentCategory << "] " - << mit->first.second << " = " << settings[mit->first] << std::endl; + Log(Debug::Verbose) << "Added new setting: [" << currentCategory << "] " + << mit->first.second << " = " << settings[mit->first]; ostream << mit->first.second << " = " << settings[mit->first] << std::endl; mit->second = true; changed = true; @@ -200,7 +200,7 @@ public: // Write the (new) current category to the file. ostream << "[" << currentCategory << "]" << std::endl; - //std::cout << "Wrote category: " << currentCategory << std::endl; + // Log(Debug::Verbose) << "Wrote category: " << currentCategory; // A setting can apparently follow the category on an input line. That's rather // inconvenient, since it makes it more likely to have duplicative sections, @@ -259,8 +259,8 @@ public: finder->second = true; // Did we really change it? if (value != settings[key]) { - std::cout << "Changed setting: [" << currentCategory << "] " - << setting << " = " << settings[key] << std::endl; + Log(Debug::Verbose) << "Changed setting: [" << currentCategory << "] " + << setting << " = " << settings[key]; changed = true; } // No need to write the current line, because we just emitted a replacement. @@ -276,8 +276,8 @@ public: // the current category at the end of the file before moving on to any new categories. for (CategorySettingStatusMap::iterator mit = written.begin(); mit != written.end(); ++mit) { if (mit->second == false && mit->first.first == currentCategory) { - std::cout << "Added new setting: [" << mit->first.first << "] " - << mit->first.second << " = " << settings[mit->first] << std::endl; + Log(Debug::Verbose) << "Added new setting: [" << mit->first.first << "] " + << mit->first.second << " = " << settings[mit->first]; ostream << mit->first.second << " = " << settings[mit->first] << std::endl; mit->second = true; changed = true; @@ -305,12 +305,12 @@ public: // If the catgory has changed, write a new category header. if (mit->first.first != currentCategory) { currentCategory = mit->first.first; - std::cout << "Created new setting section: " << mit->first.first << std::endl; + Log(Debug::Verbose) << "Created new setting section: " << mit->first.first; ostream << std::endl; ostream << "[" << currentCategory << "]" << std::endl; } - std::cout << "Added new setting: [" << mit->first.first << "] " - << mit->first.second << " = " << settings[mit->first] << std::endl; + Log(Debug::Verbose) << "Added new setting: [" << mit->first.first << "] " + << mit->first.second << " = " << settings[mit->first]; // Then write the setting. No need to mark it as written because we're done. ostream << mit->first.second << " = " << settings[mit->first] << std::endl; changed = true; @@ -319,7 +319,7 @@ public: // Now install the newly written file in the requested place. if (changed) { - std::cout << "Updating settings file: " << ipath << std::endl; + Log(Debug::Info) << "Updating settings file: " << ipath; boost::filesystem::ofstream ofstream; ofstream.open(ipath); ofstream << ostream.rdbuf(); diff --git a/components/shader/shadermanager.cpp b/components/shader/shadermanager.cpp index 5efd1b86e..28f4300c2 100644 --- a/components/shader/shadermanager.cpp +++ b/components/shader/shadermanager.cpp @@ -11,6 +11,8 @@ #include #include +#include + namespace Shader { @@ -31,13 +33,13 @@ namespace Shader size_t start = source.find('"', foundPos); if (start == std::string::npos || start == source.size()-1) { - std::cerr << "Invalid #include " << std::endl; + Log(Debug::Error) << "Invalid #include"; return false; } size_t end = source.find('"', start+1); if (end == std::string::npos) { - std::cerr << "Invalid #include " << std::endl; + Log(Debug::Error) << "Invalid #include"; return false; } std::string includeFilename = source.substr(start+1, end-(start+1)); @@ -46,7 +48,7 @@ namespace Shader includeFstream.open(includePath); if (includeFstream.fail()) { - std::cerr << "Failed to open " << includePath.string() << std::endl; + Log(Debug::Error) << "Failed to open " << includePath.string(); return false; } @@ -65,7 +67,7 @@ namespace Shader if (includedFiles.insert(includePath).second == false) { - std::cerr << "Detected cyclic #includes" << std::endl; + Log(Debug::Error) << "Detected cyclic #includes"; return false; } } @@ -81,14 +83,14 @@ namespace Shader size_t endPos = source.find_first_of(" \n\r()[].;", foundPos); if (endPos == std::string::npos) { - std::cerr << "Unexpected EOF" << std::endl; + Log(Debug::Error) << "Unexpected EOF"; return false; } std::string define = source.substr(foundPos+1, endPos - (foundPos+1)); ShaderManager::DefineMap::const_iterator defineFound = defines.find(define); if (defineFound == defines.end()) { - std::cerr << "Undefined " << define << std::endl; + Log(Debug::Error) << "Undefined " << define; return false; } else @@ -112,7 +114,7 @@ namespace Shader stream.open(p); if (stream.fail()) { - std::cerr << "Failed to open " << p.string() << std::endl; + Log(Debug::Error) << "Failed to open " << p.string(); return NULL; } std::stringstream buffer; diff --git a/components/shader/shadervisitor.cpp b/components/shader/shadervisitor.cpp index 9b3876d6c..cbd950ea3 100644 --- a/components/shader/shadervisitor.cpp +++ b/components/shader/shadervisitor.cpp @@ -10,6 +10,7 @@ #include +#include #include #include #include @@ -147,7 +148,7 @@ namespace Shader specularMap = texture; } else - std::cerr << "ShaderVisitor encountered unknown texture " << texture << std::endl; + Log(Debug::Error) << "ShaderVisitor encountered unknown texture " << texture; } } } diff --git a/components/to_utf8/to_utf8.cpp b/components/to_utf8/to_utf8.cpp index 8af0bc5ed..d4ab00381 100644 --- a/components/to_utf8/to_utf8.cpp +++ b/components/to_utf8/to_utf8.cpp @@ -2,10 +2,11 @@ #include #include -#include #include #include +#include + /* This file contains the code to translate from WINDOWS-1252 (native charset used in English version of Morrowind) to UTF-8. The library is designed to be extened to support more source encodings later, @@ -319,9 +320,7 @@ void Utf8Encoder::copyFromArray2(const char*& chp, char* &out) } } - std::ios::fmtflags f(std::cout.flags()); - std::cout << "Could not find glyph " << std::hex << (int)ch << " " << (int)ch2 << " " << (int)ch3 << std::endl; - std::cout.flags(f); + Log(Debug::Info) << "Could not find glyph " << std::hex << (int)ch << " " << (int)ch2 << " " << (int)ch3; *(out++) = ch; // Could not find glyph, just put whatever } diff --git a/components/vfs/filesystemarchive.cpp b/components/vfs/filesystemarchive.cpp index 9738e2a17..ce4ff020e 100644 --- a/components/vfs/filesystemarchive.cpp +++ b/components/vfs/filesystemarchive.cpp @@ -1,9 +1,9 @@ #include "filesystemarchive.hpp" -#include - #include +#include + namespace VFS { @@ -41,7 +41,7 @@ namespace VFS std::transform(proper.begin() + prefix, proper.end(), std::back_inserter(searchable), normalize_function); if (!mIndex.insert (std::make_pair (searchable, file)).second) - std::cerr << "Warning: found duplicate file for '" << proper << "', please check your file system for two files with the same name in different cases." << std::endl; + Log(Debug::Warning) << "Warning: found duplicate file for '" << proper << "', please check your file system for two files with the same name in different cases."; } mBuiltIndex = true; diff --git a/components/vfs/registerarchives.cpp b/components/vfs/registerarchives.cpp index a22e785cd..80e639f35 100644 --- a/components/vfs/registerarchives.cpp +++ b/components/vfs/registerarchives.cpp @@ -1,9 +1,10 @@ #include "registerarchives.hpp" #include -#include #include +#include + #include #include #include @@ -21,7 +22,7 @@ namespace VFS { // Last BSA has the highest priority const std::string archivePath = collections.getPath(*archive).string(); - std::cout << "Adding BSA archive " << archivePath << std::endl; + Log(Debug::Info) << "Adding BSA archive " << archivePath; vfs->addArchive(new BsaArchive(archivePath)); } @@ -40,12 +41,12 @@ namespace VFS { if (seen.insert(*iter).second) { - std::cout << "Adding data directory " << iter->string() << std::endl; + Log(Debug::Info) << "Adding data directory " << iter->string(); // Last data dir has the highest priority vfs->addArchive(new FileSystemArchive(iter->string())); } else - std::cerr << "Ignoring duplicate data directory " << iter->string() << std::endl; + Log(Debug::Info) << "Ignoring duplicate data directory " << iter->string(); } } diff --git a/components/widgets/imagebutton.cpp b/components/widgets/imagebutton.cpp index a3b0ae28a..2ea494ebd 100644 --- a/components/widgets/imagebutton.cpp +++ b/components/widgets/imagebutton.cpp @@ -2,6 +2,8 @@ #include +#include + namespace Gui { @@ -77,7 +79,7 @@ namespace Gui MyGUI::ITexture* texture = MyGUI::RenderManager::getInstance().getTexture(mImageNormal); if (!texture) { - std::cerr << "ImageButton: can't find " << mImageNormal << std::endl; + Log(Debug::Error) << "ImageButton: can't find image " << mImageNormal; return MyGUI::IntSize(0,0); } return MyGUI::IntSize (texture->getWidth(), texture->getHeight()); From c7a5548475f3495d6e1d711e943f4ebbbbf9dcc3 Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Tue, 14 Aug 2018 20:01:09 +0400 Subject: [PATCH 2/3] Use new logging system for editor --- apps/opencs/editor.cpp | 10 +++++----- apps/opencs/main.cpp | 3 +-- apps/opencs/model/doc/document.cpp | 5 +++-- apps/opencs/model/world/refcollection.cpp | 10 +++++----- apps/opencs/view/render/object.cpp | 4 ++-- components/files/configurationmanager.cpp | 7 +++---- 6 files changed, 19 insertions(+), 20 deletions(-) diff --git a/apps/opencs/editor.cpp b/apps/opencs/editor.cpp index 73208b926..e733d9924 100644 --- a/apps/opencs/editor.cpp +++ b/apps/opencs/editor.cpp @@ -5,8 +5,8 @@ #include #include +#include #include - #include #include "model/doc/document.hpp" @@ -294,7 +294,7 @@ bool CS::Editor::makeIPCServer() mLock = boost::interprocess::file_lock(mPid.string().c_str()); if(!mLock.try_lock()) { - std::cerr << "OpenCS already running." << std::endl; + Log(Debug::Error) << "Error: OpenMW-CS is already running."; return false; } @@ -317,17 +317,17 @@ bool CS::Editor::makeIPCServer() if(boost::filesystem::exists(fullPath.toUtf8().constData())) { // TODO: compare pid of the current process with that in the file - std::cout << "Detected unclean shutdown." << std::endl; + Log(Debug::Info) << "Detected unclean shutdown."; // delete the stale file if(remove(fullPath.toUtf8().constData())) - std::cerr << "ERROR removing stale connection file" << std::endl; + Log(Debug::Error) << "Error: can not remove stale connection file."; } } } catch(const std::exception& e) { - std::cerr << "ERROR " << e.what() << std::endl; + Log(Debug::Error) << "Error: " << e.what(); return false; } diff --git a/apps/opencs/main.cpp b/apps/opencs/main.cpp index 6058e73f9..0473291ce 100644 --- a/apps/opencs/main.cpp +++ b/apps/opencs/main.cpp @@ -1,7 +1,6 @@ #include "editor.hpp" #include -#include #include #include @@ -31,7 +30,7 @@ class Application : public QApplication } catch (const std::exception& exception) { - std::cerr << "An exception has been caught: " << exception.what() << std::endl; + Log(Debug::Error) << "An exception has been caught: " << exception.what(); } return false; diff --git a/apps/opencs/model/doc/document.cpp b/apps/opencs/model/doc/document.cpp index e45d13aa9..233b3e439 100644 --- a/apps/opencs/model/doc/document.cpp +++ b/apps/opencs/model/doc/document.cpp @@ -2,7 +2,6 @@ #include #include -#include #include #include @@ -13,6 +12,8 @@ #include #endif +#include + void CSMDoc::Document::addGmsts() { for (size_t i=0; i < CSMWorld::DefaultGmsts::FloatCount; ++i) @@ -435,7 +436,7 @@ void CSMDoc::Document::modificationStateChanged (bool clean) void CSMDoc::Document::reportMessage (const CSMDoc::Message& message, int type) { /// \todo find a better way to get these messages to the user. - std::cout << message.mMessage << std::endl; + Log(Debug::Info) << message.mMessage; } void CSMDoc::Document::operationDone2 (int type, bool failed) diff --git a/apps/opencs/model/world/refcollection.cpp b/apps/opencs/model/world/refcollection.cpp index 6b586dcec..7767cca6d 100644 --- a/apps/opencs/model/world/refcollection.cpp +++ b/apps/opencs/model/world/refcollection.cpp @@ -1,8 +1,8 @@ #include "refcollection.hpp" #include -#include +#include #include #include @@ -58,10 +58,10 @@ void CSMWorld::RefCollection::load (ESM::ESMReader& reader, int cellIndex, bool // message if (index.first != mref.mTarget[0] || index.second != mref.mTarget[1]) { - std::cerr << "The Position of moved ref " - << ref.mRefID << " does not match the target cell" << std::endl; - std::cerr << "Position: #" << index.first << " " << index.second - <<", Target #"<< mref.mTarget[0] << " " << mref.mTarget[1] << std::endl; + Log(Debug::Warning) << "Warning: the Position of moved ref " + << ref.mRefID << " does not match the target cell"; + Log(Debug::Warning) << "Position: #" << index.first << " " << index.second + <<", Target #"<< mref.mTarget[0] << " " << mref.mTarget[1]; stream.clear(); stream << "#" << mref.mTarget[0] << " " << mref.mTarget[1]; diff --git a/apps/opencs/view/render/object.cpp b/apps/opencs/view/render/object.cpp index 961b6c1c1..8301f4e9e 100644 --- a/apps/opencs/view/render/object.cpp +++ b/apps/opencs/view/render/object.cpp @@ -1,7 +1,6 @@ #include "object.hpp" #include -#include #include #include @@ -24,6 +23,7 @@ #include "../../model/world/cellcoordinates.hpp" #include "../../model/prefs/state.hpp" +#include #include #include #include @@ -133,7 +133,7 @@ void CSVRender::Object::update() catch (std::exception& e) { // TODO: use error marker mesh - std::cerr << e.what() << std::endl; + Log(Debug::Error) << e.what(); } } diff --git a/components/files/configurationmanager.cpp b/components/files/configurationmanager.cpp index 333ec5ced..c58130f96 100644 --- a/components/files/configurationmanager.cpp +++ b/components/files/configurationmanager.cpp @@ -133,7 +133,7 @@ bool ConfigurationManager::loadConfig(const boost::filesystem::path& path, if (boost::filesystem::is_regular_file(cfgFile)) { if (!mSilent) - Log(Debug::Info) << "Loading config file: " << cfgFile.string() << "... "; + Log(Debug::Info) << "Loading config file: " << cfgFile.string(); boost::filesystem::ifstream configFileStreamUnfiltered(cfgFile); boost::iostreams::filtering_istream configFileStream; @@ -144,14 +144,13 @@ bool ConfigurationManager::loadConfig(const boost::filesystem::path& path, boost::program_options::store(boost::program_options::parse_config_file( configFileStream, description, true), variables); - if (!mSilent) - Log(Debug::Info) << "done."; return true; } else { if (!mSilent) - Log(Debug::Info) << "failed."; + Log(Debug::Error) << "Loading failed."; + return false; } } From 5a4d0cec3a70e5f6e60ade7547f59cfd0a0c03d5 Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Tue, 14 Aug 2018 23:05:43 +0400 Subject: [PATCH 3/3] Use new logging system for game itself --- apps/openmw/engine.cpp | 34 ++++---- apps/openmw/main.cpp | 8 +- apps/openmw/mwclass/creature.cpp | 4 +- apps/openmw/mwclass/npc.cpp | 5 +- apps/openmw/mwdialogue/dialoguemanagerimp.cpp | 13 ++- apps/openmw/mwdialogue/scripttest.cpp | 11 +-- apps/openmw/mwgui/charactercreation.cpp | 5 +- apps/openmw/mwgui/class.cpp | 4 +- apps/openmw/mwgui/dialogue.cpp | 3 +- apps/openmw/mwgui/formatting.cpp | 3 +- apps/openmw/mwgui/loadingscreen.cpp | 5 +- apps/openmw/mwgui/messagebox.cpp | 3 +- apps/openmw/mwgui/race.cpp | 3 +- apps/openmw/mwgui/savegamedialog.cpp | 6 +- apps/openmw/mwgui/settingswindow.cpp | 6 +- apps/openmw/mwgui/sortfilteritemmodel.cpp | 6 +- apps/openmw/mwgui/spellmodel.cpp | 4 +- apps/openmw/mwgui/videowidget.cpp | 3 +- apps/openmw/mwgui/windowmanagerimp.cpp | 6 +- apps/openmw/mwinput/inputmanagerimp.cpp | 5 +- apps/openmw/mwmechanics/actors.cpp | 4 +- apps/openmw/mwmechanics/aisequence.cpp | 4 +- apps/openmw/mwmechanics/aiwander.cpp | 7 +- apps/openmw/mwmechanics/levelledlist.hpp | 5 +- apps/openmw/mwmechanics/objects.cpp | 4 +- apps/openmw/mwmechanics/summoning.cpp | 4 +- apps/openmw/mwphysics/physicssystem.cpp | 7 +- apps/openmw/mwrender/animation.cpp | 12 +-- apps/openmw/mwrender/bulletdebugdraw.cpp | 6 +- apps/openmw/mwrender/characterpreview.cpp | 4 +- apps/openmw/mwrender/creatureanimation.cpp | 6 +- apps/openmw/mwrender/globalmap.cpp | 12 +-- apps/openmw/mwrender/localmap.cpp | 14 ++-- apps/openmw/mwrender/npcanimation.cpp | 12 +-- apps/openmw/mwrender/renderingmanager.cpp | 6 +- apps/openmw/mwrender/water.cpp | 9 +- apps/openmw/mwscript/aiextensions.cpp | 19 ++--- apps/openmw/mwscript/containerextensions.cpp | 6 +- apps/openmw/mwscript/dialogueextensions.cpp | 8 +- apps/openmw/mwscript/globalscripts.cpp | 11 ++- apps/openmw/mwscript/locals.cpp | 10 +-- apps/openmw/mwscript/scriptmanagerimp.cpp | 13 +-- apps/openmw/mwscript/statsextensions.cpp | 8 +- .../mwscript/transformationextensions.cpp | 6 +- apps/openmw/mwsound/ffmpeg_decoder.cpp | 10 +-- apps/openmw/mwsound/openal_output.cpp | 83 ++++++++++--------- apps/openmw/mwsound/soundmanagerimp.cpp | 28 ++++--- apps/openmw/mwstate/statemanagerimp.cpp | 18 ++-- apps/openmw/mwworld/cellpreloader.cpp | 7 +- apps/openmw/mwworld/cells.cpp | 5 +- apps/openmw/mwworld/cellstore.cpp | 28 +++---- apps/openmw/mwworld/containerstore.cpp | 7 +- apps/openmw/mwworld/contentloader.hpp | 6 +- apps/openmw/mwworld/esmstore.cpp | 9 +- apps/openmw/mwworld/inventorystore.cpp | 3 +- apps/openmw/mwworld/livecellref.cpp | 10 +-- apps/openmw/mwworld/localscripts.cpp | 14 ++-- apps/openmw/mwworld/player.cpp | 7 +- apps/openmw/mwworld/projectilemanager.cpp | 5 +- apps/openmw/mwworld/scene.cpp | 14 ++-- apps/openmw/mwworld/store.cpp | 5 +- apps/openmw/mwworld/worldimp.cpp | 14 ++-- 62 files changed, 310 insertions(+), 297 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index bd40dc1ab..2941ede1b 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -10,6 +10,8 @@ #include +#include + #include #include @@ -61,7 +63,7 @@ namespace void checkSDLError(int ret) { if (ret != 0) - std::cerr << "SDL error: " << SDL_GetError() << std::endl; + Log(Debug::Error) << "SDL error: " << SDL_GetError(); } } @@ -189,7 +191,7 @@ bool OMW::Engine::frame(float frametime) } catch (const std::exception& e) { - std::cerr << "Error in frame: " << e.what() << std::endl; + Log(Debug::Error) << "Error in frame: " << e.what(); } return true; } @@ -364,7 +366,7 @@ void OMW::Engine::createWindow(Settings::Manager& settings) // Try with a lower AA if (antialiasing > 0) { - std::cout << "Note: " << antialiasing << "x antialiasing not supported, trying " << antialiasing/2 << std::endl; + Log(Debug::Warning) << "Warning: " << antialiasing << "x antialiasing not supported, trying " << antialiasing/2; antialiasing /= 2; Settings::Manager::setInt("antialiasing", "Video", antialiasing); checkSDLError(SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, antialiasing)); @@ -373,7 +375,7 @@ void OMW::Engine::createWindow(Settings::Manager& settings) else { std::stringstream error; - error << "Failed to create SDL window: " << SDL_GetError() << std::endl; + error << "Failed to create SDL window: " << SDL_GetError(); throw std::runtime_error(error.str()); } } @@ -420,16 +422,16 @@ void OMW::Engine::setWindowIcon() std::string windowIcon = (mResDir / "mygui" / "openmw.png").string(); windowIconStream.open(windowIcon, std::ios_base::in | std::ios_base::binary); if (windowIconStream.fail()) - std::cerr << "Error: Failed to open " << windowIcon << std::endl; + Log(Debug::Error) << "Error: Failed to open " << windowIcon; osgDB::ReaderWriter* reader = osgDB::Registry::instance()->getReaderWriterForExtension("png"); if (!reader) { - std::cerr << "Error: Failed to read window icon, no png readerwriter found" << std::endl; + Log(Debug::Error) << "Error: Failed to read window icon, no png readerwriter found"; return; } osgDB::ReaderWriter::ReadResult result = reader->readImage(windowIconStream); if (!result.success()) - std::cerr << "Error: Failed to read " << windowIcon << ": " << result.message() << " code " << result.status() << std::endl; + Log(Debug::Error) << "Error: Failed to read " << windowIcon << ": " << result.message() << " code " << result.status(); else { osg::ref_ptr image = result.getImage(); @@ -564,21 +566,19 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings) { std::pair result = mEnvironment.getScriptManager()->compileAll(); if (result.first) - std::cout + Log(Debug::Info) << "compiled " << result.second << " of " << result.first << " scripts (" << 100*static_cast (result.second)/result.first - << "%)" - << std::endl; + << "%)"; } if (mCompileAllDialogue) { std::pair result = MWDialogue::ScriptTest::compileAll(&mExtensions, mWarningsMode); if (result.first) - std::cout + Log(Debug::Info) << "compiled " << result.second << " of " << result.first << " dialogue script/actor combinations a(" << 100*static_cast (result.second)/result.first - << "%)" - << std::endl; + << "%)"; } } @@ -614,14 +614,14 @@ public: osgDB::ReaderWriter* readerwriter = osgDB::Registry::instance()->getReaderWriterForExtension(mScreenshotFormat); if (!readerwriter) { - std::cerr << "Error: Can't write screenshot, no '" << mScreenshotFormat << "' readerwriter found" << std::endl; + Log(Debug::Error) << "Error: Can't write screenshot, no '" << mScreenshotFormat << "' readerwriter found"; return; } osgDB::ReaderWriter::WriteResult result = readerwriter->writeImage(image, outStream); if (!result.success()) { - std::cerr << "Error: Can't write screenshot: " << result.message() << " code " << result.status() << std::endl; + Log(Debug::Error) << "Error: Can't write screenshot: " << result.message() << " code " << result.status(); } } @@ -636,7 +636,7 @@ void OMW::Engine::go() { assert (!mContentFiles.empty()); - std::cout << "OSG version: " << osgGetVersion() << std::endl; + Log(Debug::Info) << "OSG version: " << osgGetVersion(); // Load settings Settings::Manager settings; @@ -738,7 +738,7 @@ void OMW::Engine::go() // Save user settings settings.saveUser(settingspath); - std::cout << "Quitting peacefully." << std::endl; + Log(Debug::Info) << "Quitting peacefully."; } void OMW::Engine::setCompileAll (bool all) diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp index f9cf58544..176adfad0 100644 --- a/apps/openmw/main.cpp +++ b/apps/openmw/main.cpp @@ -1,5 +1,3 @@ -#include - #include #include #include @@ -202,8 +200,8 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat StringsVector content = variables["content"].as().toStdStringVector(); if (content.empty()) { - std::cout << "No content file given (esm/esp, nor omwgame/omwaddon). Aborting..." << std::endl; - return false; + Log(Debug::Error) << "No content file given (esm/esp, nor omwgame/omwaddon). Aborting..."; + return false; } StringsVector::const_iterator it(content.begin()); @@ -217,7 +215,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat engine.setCell(variables["start"].as().toStdString()); engine.setSkipMenu (variables["skip-menu"].as(), variables["new-game"].as()); if (!variables["skip-menu"].as() && variables["new-game"].as()) - std::cerr << "Warning: new-game used without skip-menu -> ignoring it" << std::endl; + Log(Debug::Warning) << "Warning: new-game used without skip-menu -> ignoring it"; // scripts engine.setCompileAll(variables["script-all"].as()); diff --git a/apps/openmw/mwclass/creature.cpp b/apps/openmw/mwclass/creature.cpp index 02a8a17ef..161711751 100644 --- a/apps/openmw/mwclass/creature.cpp +++ b/apps/openmw/mwclass/creature.cpp @@ -1,7 +1,7 @@ #include "creature.hpp" #include - +#include #include #include #include @@ -146,7 +146,7 @@ namespace MWClass if (const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get().search(*iter)) data->mCreatureStats.getSpells().add (spell); else /// \todo add option to make this a fatal error message pop-up, but default to warning for vanilla compatibility - std::cerr << "Warning: ignoring nonexistent spell '" << *iter << "' on creature '" << ref->mBase->mId << "'" << std::endl; + Log(Debug::Warning) << "Warning: ignoring nonexistent spell '" << *iter << "' on creature '" << ref->mBase->mId << "'"; } // inventory diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index 1c293f1e4..c06c3f67c 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -4,6 +4,7 @@ #include +#include #include #include #include @@ -365,7 +366,7 @@ namespace MWClass if (const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get().search(*iter)) data->mNpcStats.getSpells().add (spell); else - std::cerr << "Warning: ignoring nonexistent race power '" << *iter << "' on NPC '" << ref->mBase->mId << "'" << std::endl; + Log(Debug::Warning) << "Warning: ignoring nonexistent race power '" << *iter << "' on NPC '" << ref->mBase->mId << "'"; } if (!ref->mBase->mFaction.empty()) @@ -395,7 +396,7 @@ namespace MWClass else { /// \todo add option to make this a fatal error message pop-up, but default to warning for vanilla compatibility - std::cerr << "Warning: ignoring nonexistent spell '" << *iter << "' on NPC '" << ref->mBase->mId << "'" << std::endl; + Log(Debug::Warning) << "Warning: ignoring nonexistent spell '" << *iter << "' on NPC '" << ref->mBase->mId << "'"; } } diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp index df214ce86..c3e56c0bf 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp @@ -5,7 +5,8 @@ #include #include #include -#include + +#include #include #include @@ -203,16 +204,14 @@ namespace MWDialogue } catch (const std::exception& error) { - std::cerr << std::string ("Dialogue error: An exception has been thrown: ") + error.what() << std::endl; + Log(Debug::Error) << std::string ("Dialogue error: An exception has been thrown: ") + error.what(); success = false; } if (!success) { - std::cerr - << "Warning: compiling failed (dialogue script)" << std::endl - << cmd - << std::endl << std::endl; + Log(Debug::Warning) + << "Warning: compiling failed (dialogue script)\n" << cmd << "\n\n"; } return success; @@ -232,7 +231,7 @@ namespace MWDialogue } catch (const std::exception& error) { - std::cerr << std::string ("Dialogue error: An exception has been thrown: ") + error.what() << std::endl; + Log(Debug::Error) << std::string ("Dialogue error: An exception has been thrown: ") + error.what(); } } } diff --git a/apps/openmw/mwdialogue/scripttest.cpp b/apps/openmw/mwdialogue/scripttest.cpp index 54b4d8cd9..4f0b7422c 100644 --- a/apps/openmw/mwdialogue/scripttest.cpp +++ b/apps/openmw/mwdialogue/scripttest.cpp @@ -1,7 +1,5 @@ #include "scripttest.hpp" -#include - #include "../mwworld/manualref.hpp" #include "../mwworld/esmstore.hpp" #include "../mwworld/class.hpp" @@ -12,6 +10,7 @@ #include "../mwscript/compilercontext.hpp" +#include #include #include #include @@ -80,16 +79,14 @@ void test(const MWWorld::Ptr& actor, int &compiled, int &total, const Compiler:: } catch (const std::exception& error) { - std::cerr << std::string ("Dialogue error: An exception has been thrown: ") + error.what() << std::endl; + Log(Debug::Error) << std::string ("Dialogue error: An exception has been thrown: ") + error.what(); success = false; } if (!success) { - std::cerr - << "compiling failed (dialogue script)" << std::endl - << info->mResultScript - << std::endl << std::endl; + Log(Debug::Warning) + << "compiling failed (dialogue script)\n" << info->mResultScript << "\n\n"; } } } diff --git a/apps/openmw/mwgui/charactercreation.cpp b/apps/openmw/mwgui/charactercreation.cpp index 2deb62215..e3effa995 100644 --- a/apps/openmw/mwgui/charactercreation.cpp +++ b/apps/openmw/mwgui/charactercreation.cpp @@ -1,5 +1,6 @@ #include "charactercreation.hpp" +#include #include #include "../mwbase/environment.hpp" @@ -284,7 +285,7 @@ namespace MWGui } catch (std::exception& e) { - std::cerr << "Error: Failed to create chargen window: " << e.what() << std::endl; + Log(Debug::Error) << "Error: Failed to create chargen window: " << e.what(); } } @@ -602,7 +603,7 @@ namespace MWGui mGenerateClass = "Mage"; else { - std::cout << "Failed to deduce class from chosen answers in generate class dialog" << std::endl; + Log(Debug::Warning) << "Failed to deduce class from chosen answers in generate class dialog."; mGenerateClass = "Thief"; } } diff --git a/apps/openmw/mwgui/class.cpp b/apps/openmw/mwgui/class.cpp index 4d2a15c82..6ed7a4491 100644 --- a/apps/openmw/mwgui/class.cpp +++ b/apps/openmw/mwgui/class.cpp @@ -12,6 +12,8 @@ #include "../mwworld/esmstore.hpp" +#include + #include "tooltips.hpp" namespace @@ -924,7 +926,7 @@ namespace MWGui std::string classImage = std::string("textures\\levelup\\") + classId + ".dds"; if (!MWBase::Environment::get().getWindowManager()->textureExists(classImage)) { - std::cout << "No class image for " << classId << ", falling back to default" << std::endl; + Log(Debug::Warning) << "No class image for " << classId << ", falling back to default"; classImage = "textures\\levelup\\warrior.dds"; } imageBox->setImageTexture(classImage); diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index 7b177fdb0..aeb6dfc0f 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -6,6 +6,7 @@ #include #include +#include #include #include @@ -411,7 +412,7 @@ namespace MWGui { if (!actor.getClass().isActor()) { - std::cerr << "Warning: can not talk with non-actor object." << std::endl; + Log(Debug::Warning) << "Warning: can not talk with non-actor object."; return; } diff --git a/apps/openmw/mwgui/formatting.cpp b/apps/openmw/mwgui/formatting.cpp index edcb94eed..663bd7338 100644 --- a/apps/openmw/mwgui/formatting.cpp +++ b/apps/openmw/mwgui/formatting.cpp @@ -13,6 +13,7 @@ #include #include +#include #include #include @@ -300,7 +301,7 @@ namespace MWGui if (!exists) { - std::cerr << "Warning: Could not find \"" << src << "\" referenced by an tag." << std::endl; + Log(Debug::Warning) << "Warning: Could not find \"" << src << "\" referenced by an tag."; break; } diff --git a/apps/openmw/mwgui/loadingscreen.cpp b/apps/openmw/mwgui/loadingscreen.cpp index 28f4b8890..be3d477e1 100644 --- a/apps/openmw/mwgui/loadingscreen.cpp +++ b/apps/openmw/mwgui/loadingscreen.cpp @@ -10,9 +10,8 @@ #include #include - +#include #include - #include #include @@ -94,7 +93,7 @@ namespace MWGui ++found; } if (mSplashScreens.empty()) - std::cerr << "No splash screens found!" << std::endl; + Log(Debug::Warning) << "Warning: no splash screens found!"; } void LoadingScreen::setLabel(const std::string &label, bool important) diff --git a/apps/openmw/mwgui/messagebox.cpp b/apps/openmw/mwgui/messagebox.cpp index a79112b9f..2fbce97d4 100644 --- a/apps/openmw/mwgui/messagebox.cpp +++ b/apps/openmw/mwgui/messagebox.cpp @@ -5,6 +5,7 @@ #include #include +#include #include #include "../mwbase/environment.hpp" @@ -125,7 +126,7 @@ namespace MWGui { if (mInterMessageBoxe != NULL) { - std::cerr << "Warning: replacing an interactive message box that was not answered yet" << std::endl; + Log(Debug::Warning) << "Warning: replacing an interactive message box that was not answered yet"; mInterMessageBoxe->setVisible(false); delete mInterMessageBoxe; mInterMessageBoxe = NULL; diff --git a/apps/openmw/mwgui/race.cpp b/apps/openmw/mwgui/race.cpp index 64609cbe6..96c0d7de4 100644 --- a/apps/openmw/mwgui/race.cpp +++ b/apps/openmw/mwgui/race.cpp @@ -6,6 +6,7 @@ #include +#include #include #include "../mwworld/esmstore.hpp" @@ -340,7 +341,7 @@ namespace MWGui } catch (std::exception& e) { - std::cerr << "Error creating preview: " << e.what() << std::endl; + Log(Debug::Error) << "Error creating preview: " << e.what(); } } diff --git a/apps/openmw/mwgui/savegamedialog.cpp b/apps/openmw/mwgui/savegamedialog.cpp index 43e511144..45790cbf5 100644 --- a/apps/openmw/mwgui/savegamedialog.cpp +++ b/apps/openmw/mwgui/savegamedialog.cpp @@ -12,6 +12,8 @@ #include #include +#include + #include #include @@ -438,14 +440,14 @@ namespace MWGui osgDB::ReaderWriter* readerwriter = osgDB::Registry::instance()->getReaderWriterForExtension("jpg"); if (!readerwriter) { - std::cerr << "Error: Can't open savegame screenshot, no jpg readerwriter found" << std::endl; + Log(Debug::Error) << "Error: Can't open savegame screenshot, no jpg readerwriter found"; return; } osgDB::ReaderWriter::ReadResult result = readerwriter->readImage(instream); if (!result.success()) { - std::cerr << "Error: Failed to read savegame screenshot: " << result.message() << " code " << result.status() << std::endl; + Log(Debug::Error) << "Error: Failed to read savegame screenshot: " << result.message() << " code " << result.status(); return; } diff --git a/apps/openmw/mwgui/settingswindow.cpp b/apps/openmw/mwgui/settingswindow.cpp index 677ddefb3..80ed9202a 100644 --- a/apps/openmw/mwgui/settingswindow.cpp +++ b/apps/openmw/mwgui/settingswindow.cpp @@ -12,6 +12,7 @@ #include +#include #include #include @@ -31,7 +32,8 @@ namespace if (val == "linear") return "Trilinear"; if (val == "nearest") return "Bilinear"; if (val != "none") - std::cerr<< "Warning: Invalid texture mipmap option: "< - #include - +#include #include #include #include @@ -245,7 +243,7 @@ namespace MWGui const ESM::Enchantment* ench = MWBase::Environment::get().getWorld()->getStore().get().search(enchId); if (!ench) { - std::cerr << "Warning: Can't find enchantment '" << enchId << "' on item " << base.getCellRef().getRefId() << std::endl; + Log(Debug::Warning) << "Warning: Can't find enchantment '" << enchId << "' on item " << base.getCellRef().getRefId(); return false; } diff --git a/apps/openmw/mwgui/spellmodel.cpp b/apps/openmw/mwgui/spellmodel.cpp index a2710b633..0933737ca 100644 --- a/apps/openmw/mwgui/spellmodel.cpp +++ b/apps/openmw/mwgui/spellmodel.cpp @@ -1,6 +1,6 @@ #include "spellmodel.hpp" -#include +#include #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" @@ -94,7 +94,7 @@ namespace MWGui const ESM::Enchantment* enchant = esmStore.get().search(enchantId); if (!enchant) { - std::cerr << "Warning: Can't find enchantment '" << enchantId << "' on item " << item.getCellRef().getRefId() << std::endl; + Log(Debug::Warning) << "Warning: Can't find enchantment '" << enchantId << "' on item " << item.getCellRef().getRefId(); continue; } diff --git a/apps/openmw/mwgui/videowidget.cpp b/apps/openmw/mwgui/videowidget.cpp index 5a4bb981f..516f5cfcc 100644 --- a/apps/openmw/mwgui/videowidget.cpp +++ b/apps/openmw/mwgui/videowidget.cpp @@ -6,6 +6,7 @@ #include +#include #include #include @@ -37,7 +38,7 @@ void VideoWidget::playVideo(const std::string &video) } catch (std::exception& e) { - std::cerr << "Failed to open video: " << e.what() << std::endl; + Log(Debug::Error) << "Failed to open video: " << e.what(); return; } diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index c97efed34..e1bf9627d 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -21,6 +21,8 @@ #include #include +#include + #include #include @@ -1082,7 +1084,7 @@ namespace MWGui { if (!mStore) { - std::cerr << "Error: WindowManager::onRetrieveTag: no Store set up yet, can not replace '" << tag << "'" << std::endl; + Log(Debug::Error) << "Error: WindowManager::onRetrieveTag: no Store set up yet, can not replace '" << tag << "'"; return; } const ESM::GameSetting *setting = mStore->get().find(tag); @@ -1788,7 +1790,7 @@ namespace MWGui if (found != mCurrentModals.end()) mCurrentModals.erase(found); else - std::cerr << " warning: can't find modal window " << input << std::endl; + Log(Debug::Warning) << "Warning: can't find modal window " << input; } } if (mCurrentModals.empty()) diff --git a/apps/openmw/mwinput/inputmanagerimp.cpp b/apps/openmw/mwinput/inputmanagerimp.cpp index 242058c5f..709c61196 100644 --- a/apps/openmw/mwinput/inputmanagerimp.cpp +++ b/apps/openmw/mwinput/inputmanagerimp.cpp @@ -10,6 +10,7 @@ #include +#include #include #include #include @@ -120,11 +121,11 @@ namespace MWInput SDL_ControllerDeviceEvent evt; evt.which = i; controllerAdded(mFakeDeviceID, evt); - std::cout << "Detected game controller: " << SDL_GameControllerNameForIndex(i) << std::endl; + Log(Debug::Info) << "Detected game controller: " << SDL_GameControllerNameForIndex(i); } else { - std::cout << "Detected unusable controller: " << SDL_JoystickNameForIndex(i) << std::endl; + Log(Debug::Info) << "Detected unusable controller: " << SDL_JoystickNameForIndex(i); } } diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index 2d535f57b..d1f4e47df 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -8,7 +8,7 @@ #include #include - +#include #include #include "../mwworld/esmstore.hpp" @@ -1720,7 +1720,7 @@ namespace MWMechanics } else { - std::cerr<< "Warning: Actors::playAnimationGroup: Unable to find " << ptr.getCellRef().getRefId() << std::endl; + Log(Debug::Warning) << "Warning: Actors::playAnimationGroup: Unable to find " << ptr.getCellRef().getRefId(); return false; } } diff --git a/apps/openmw/mwmechanics/aisequence.cpp b/apps/openmw/mwmechanics/aisequence.cpp index 085174820..753dc240e 100644 --- a/apps/openmw/mwmechanics/aisequence.cpp +++ b/apps/openmw/mwmechanics/aisequence.cpp @@ -1,8 +1,8 @@ #include "aisequence.hpp" #include -#include +#include #include #include "../mwbase/environment.hpp" @@ -282,7 +282,7 @@ void AiSequence::execute (const MWWorld::Ptr& actor, CharacterController& charac } catch (std::exception& e) { - std::cerr << "Error during AiSequence::execute: " << e.what() << std::endl; + Log(Debug::Error) << "Error during AiSequence::execute: " << e.what(); } } } diff --git a/apps/openmw/mwmechanics/aiwander.cpp b/apps/openmw/mwmechanics/aiwander.cpp index 928b09cf9..67468453a 100644 --- a/apps/openmw/mwmechanics/aiwander.cpp +++ b/apps/openmw/mwmechanics/aiwander.cpp @@ -1,10 +1,9 @@ #include "aiwander.hpp" #include -#include +#include #include - #include #include "../mwbase/world.hpp" @@ -24,8 +23,6 @@ #include "coordinateconverter.hpp" #include "actorutil.hpp" - - namespace MWMechanics { static const int COUNT_BEFORE_RESET = 10; @@ -677,7 +674,7 @@ namespace MWMechanics } else { - std::cerr<< "Error: Attempted to play out of range idle animation \""< - +#include #include #include "../mwworld/ptr.hpp" @@ -63,7 +62,7 @@ namespace MWMechanics // Vanilla doesn't fail on nonexistent items in levelled lists if (!MWBase::Environment::get().getWorld()->getStore().find(Misc::StringUtils::lowerCase(item))) { - std::cerr << "Warning: ignoring nonexistent item '" << item << "' in levelled list '" << levItem->mId << "'" << std::endl; + Log(Debug::Warning) << "Warning: ignoring nonexistent item '" << item << "' in levelled list '" << levItem->mId << "'"; return std::string(); } diff --git a/apps/openmw/mwmechanics/objects.cpp b/apps/openmw/mwmechanics/objects.cpp index 7d7a5f14f..d8821276e 100644 --- a/apps/openmw/mwmechanics/objects.cpp +++ b/apps/openmw/mwmechanics/objects.cpp @@ -1,6 +1,6 @@ #include "objects.hpp" -#include +#include #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" @@ -88,7 +88,7 @@ bool Objects::playAnimationGroup(const MWWorld::Ptr& ptr, const std::string& gro } else { - std::cerr<< "Warning: Objects::playAnimationGroup: Unable to find " << ptr.getCellRef().getRefId() << std::endl; + Log(Debug::Warning) << "Warning: Objects::playAnimationGroup: Unable to find " << ptr.getCellRef().getRefId(); return false; } } diff --git a/apps/openmw/mwmechanics/summoning.cpp b/apps/openmw/mwmechanics/summoning.cpp index 71c49f9df..b3f7afc53 100644 --- a/apps/openmw/mwmechanics/summoning.cpp +++ b/apps/openmw/mwmechanics/summoning.cpp @@ -1,6 +1,6 @@ #include "summoning.hpp" -#include +#include #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" @@ -76,7 +76,7 @@ namespace MWMechanics } catch (std::exception& e) { - std::cerr << "Failed to spawn summoned creature: " << e.what() << std::endl; + Log(Debug::Error) << "Failed to spawn summoned creature: " << e.what(); // still insert into creatureMap so we don't try to spawn again every frame, that would spam the warning log } diff --git a/apps/openmw/mwphysics/physicssystem.cpp b/apps/openmw/mwphysics/physicssystem.cpp index ae8d76a80..13a0f23ac 100644 --- a/apps/openmw/mwphysics/physicssystem.cpp +++ b/apps/openmw/mwphysics/physicssystem.cpp @@ -1,6 +1,5 @@ #include "physicssystem.hpp" -#include #include #include @@ -20,7 +19,7 @@ #include #include #include - +#include #include #include #include @@ -638,7 +637,7 @@ namespace MWPhysics mPtr.getRefData().getBaseNode()->accept(visitor); if (!visitor.mFound) { - std::cerr << "Error: animateCollisionShapes can't find node " << recIndex << " for " << mPtr.getCellRef().getRefId() << std::endl; + Log(Debug::Warning) << "Warning: animateCollisionShapes can't find node " << recIndex << " for " << mPtr.getCellRef().getRefId(); // Remove nonexistent nodes from animated shapes map and early out mShapeInstance->mAnimatedShapes.erase(recIndex); @@ -708,7 +707,7 @@ namespace MWPhysics if (physFramerate > 0) { mPhysicsDt = 1.f / physFramerate; - std::cerr << "Warning: physics framerate was overridden (a new value is " << physFramerate << ")." << std::endl; + Log(Debug::Warning) << "Warning: using custom physics framerate (" << physFramerate << " FPS)."; } } } diff --git a/apps/openmw/mwrender/animation.cpp b/apps/openmw/mwrender/animation.cpp index ff31e1cfb..8e1105b9f 100644 --- a/apps/openmw/mwrender/animation.cpp +++ b/apps/openmw/mwrender/animation.cpp @@ -12,6 +12,8 @@ #include #include +#include + #include #include @@ -192,7 +194,7 @@ namespace for (RemoveVec::iterator it = mToRemove.begin(); it != mToRemove.end(); ++it) { if (!it->second->removeChild(it->first)) - std::cerr << "error removing " << it->first->getName() << std::endl; + Log(Debug::Error) << "Error removing " << it->first->getName(); } } @@ -612,7 +614,7 @@ namespace MWRender NodeMap::const_iterator found = nodeMap.find(bonename); if (found == nodeMap.end()) { - std::cerr << "Warning: addAnimSource: can't find bone '" + bonename << "' in " << baseModel << " (referenced by " << kfname << ")" << std::endl; + Log(Debug::Warning) << "Warning: addAnimSource: can't find bone '" + bonename << "' in " << baseModel << " (referenced by " << kfname << ")"; continue; } @@ -724,7 +726,7 @@ namespace MWRender } catch (std::exception& e) { - std::cerr << "Error handling text key " << evt << ": " << e.what() << std::endl; + Log(Debug::Error) << "Error handling text key " << evt << ": " << e.what(); } } } @@ -1767,12 +1769,12 @@ namespace MWRender PartHolder::~PartHolder() { if (mNode.get() && !mNode->getNumParents()) - std::cerr << "Error: part has no parents " << std::endl; + Log(Debug::Verbose) << "Part has no parents" ; if (mNode.get() && mNode->getNumParents()) { if (mNode->getNumParents() > 1) - std::cerr << "Error: part has multiple parents " << mNode->getNumParents() << " " << mNode.get() << std::endl; + Log(Debug::Verbose) << "Part has multiple (" << mNode->getNumParents() << ") parents"; mNode->getParent(0)->removeChild(mNode); } } diff --git a/apps/openmw/mwrender/bulletdebugdraw.cpp b/apps/openmw/mwrender/bulletdebugdraw.cpp index d35c3ac5d..eb3775cb4 100644 --- a/apps/openmw/mwrender/bulletdebugdraw.cpp +++ b/apps/openmw/mwrender/bulletdebugdraw.cpp @@ -1,12 +1,12 @@ #include "bulletdebugdraw.hpp" -#include - #include #include #include +#include + #include "vismask.hpp" namespace @@ -91,7 +91,7 @@ void DebugDrawer::drawContactPoint(const btVector3 &PointOnB, const btVector3 &n void DebugDrawer::reportErrorWarning(const char *warningString) { - std::cerr << warningString << std::endl; + Log(Debug::Warning) << warningString; } void DebugDrawer::setDebugMode(int isOn) diff --git a/apps/openmw/mwrender/characterpreview.cpp b/apps/openmw/mwrender/characterpreview.cpp index faaa3799e..2e0249e60 100644 --- a/apps/openmw/mwrender/characterpreview.cpp +++ b/apps/openmw/mwrender/characterpreview.cpp @@ -1,7 +1,6 @@ #include "characterpreview.hpp" #include -#include #include #include @@ -14,6 +13,7 @@ #include #include +#include #include #include @@ -474,7 +474,7 @@ namespace MWRender mCamera->addUpdateCallback(mUpdateCameraCallback); } else - std::cerr << "Error: Bip01 Head node not found" << std::endl; + Log(Debug::Error) << "Error: Bip01 Head node not found"; } } diff --git a/apps/openmw/mwrender/creatureanimation.cpp b/apps/openmw/mwrender/creatureanimation.cpp index 827b576c3..6db223bd5 100644 --- a/apps/openmw/mwrender/creatureanimation.cpp +++ b/apps/openmw/mwrender/creatureanimation.cpp @@ -1,11 +1,9 @@ #include "creatureanimation.hpp" -#include - #include #include - +#include #include #include #include @@ -155,7 +153,7 @@ void CreatureWeaponAnimation::updatePart(PartHolderPtr& scene, int slot) } catch (std::exception& e) { - std::cerr << "Can not add creature part: " << e.what() << std::endl; + Log(Debug::Error) << "Can not add creature part: " << e.what(); } } diff --git a/apps/openmw/mwrender/globalmap.cpp b/apps/openmw/mwrender/globalmap.cpp index af2bb101a..fae524faa 100644 --- a/apps/openmw/mwrender/globalmap.cpp +++ b/apps/openmw/mwrender/globalmap.cpp @@ -15,6 +15,8 @@ #include #include +#include + #include #include @@ -411,14 +413,14 @@ namespace MWRender osgDB::ReaderWriter* readerwriter = osgDB::Registry::instance()->getReaderWriterForExtension("png"); if (!readerwriter) { - std::cerr << "Error: Can't write map overlay: no png readerwriter found" << std::endl; + Log(Debug::Error) << "Error: Can't write map overlay: no png readerwriter found"; return; } osgDB::ReaderWriter::WriteResult result = readerwriter->writeImage(*mOverlayImage, ostream); if (!result.success()) { - std::cerr << "Error: Can't write map overlay: " << result.message() << " code " << result.status() << std::endl; + Log(Debug::Warning) << "Error: Can't write map overlay: " << result.message() << " code " << result.status(); return; } @@ -463,14 +465,14 @@ namespace MWRender osgDB::ReaderWriter* readerwriter = osgDB::Registry::instance()->getReaderWriterForExtension("png"); if (!readerwriter) { - std::cerr << "Error: Can't read map overlay: no png readerwriter found" << std::endl; + Log(Debug::Error) << "Error: Can't read map overlay: no png readerwriter found"; return; } osgDB::ReaderWriter::ReadResult result = readerwriter->readImage(istream); if (!result.success()) { - std::cerr << "Error: Can't read map overlay: " << result.message() << " code " << result.status() << std::endl; + Log(Debug::Error) << "Error: Can't read map overlay: " << result.message() << " code " << result.status(); return; } @@ -572,7 +574,7 @@ namespace MWRender CameraVector::iterator found = std::find(mActiveCameras.begin(), mActiveCameras.end(), camera); if (found == mActiveCameras.end()) { - std::cerr << "Error: GlobalMap trying to remove an inactive camera" << std::endl; + Log(Debug::Error) << "Error: GlobalMap trying to remove an inactive camera"; return; } mActiveCameras.erase(found); diff --git a/apps/openmw/mwrender/localmap.cpp b/apps/openmw/mwrender/localmap.cpp index 0b65a6b13..5e501ecf8 100644 --- a/apps/openmw/mwrender/localmap.cpp +++ b/apps/openmw/mwrender/localmap.cpp @@ -1,6 +1,5 @@ #include "localmap.hpp" -#include #include #include @@ -12,6 +11,7 @@ #include +#include #include #include #include @@ -320,7 +320,7 @@ void LocalMap::markForRemoval(osg::Camera *cam) CameraVector::iterator found = std::find(mActiveCameras.begin(), mActiveCameras.end(), cam); if (found == mActiveCameras.end()) { - std::cerr << "Error: trying to remove an inactive camera" << std::endl; + Log(Debug::Error) << "Error: trying to remove an inactive camera"; return; } mActiveCameras.erase(found); @@ -492,7 +492,7 @@ void LocalMap::requestInteriorMap(const MWWorld::CellStore* cell) // We are using the same bounds and angle as we were using when the textures were originally made. Segments should come out the same. if (i >= int(fog->mFogTextures.size())) { - std::cout << "Error: fog texture count mismatch" << std::endl; + Log(Debug::Warning) << "Warning: fog texture count mismatch"; break; } @@ -684,7 +684,7 @@ void LocalMap::MapSegment::loadFogOfWar(const ESM::FogTexture &esm) osgDB::ReaderWriter* readerwriter = osgDB::Registry::instance()->getReaderWriterForExtension("tga"); if (!readerwriter) { - std::cerr << "Error: Unable to load fog, can't find a tga ReaderWriter" << std::endl; + Log(Debug::Error) << "Error: Unable to load fog, can't find a tga ReaderWriter" ; return; } @@ -693,7 +693,7 @@ void LocalMap::MapSegment::loadFogOfWar(const ESM::FogTexture &esm) osgDB::ReaderWriter::ReadResult result = readerwriter->readImage(in); if (!result.success()) { - std::cerr << "Error: Failed to read fog: " << result.message() << " code " << result.status() << std::endl; + Log(Debug::Error) << "Error: Failed to read fog: " << result.message() << " code " << result.status(); return; } @@ -716,7 +716,7 @@ void LocalMap::MapSegment::saveFogOfWar(ESM::FogTexture &fog) const osgDB::ReaderWriter* readerwriter = osgDB::Registry::instance()->getReaderWriterForExtension("tga"); if (!readerwriter) { - std::cerr << "Error: Unable to write fog, can't find a tga ReaderWriter" << std::endl; + Log(Debug::Error) << "Error: Unable to write fog, can't find a tga ReaderWriter"; return; } @@ -725,7 +725,7 @@ void LocalMap::MapSegment::saveFogOfWar(ESM::FogTexture &fog) const osgDB::ReaderWriter::WriteResult result = readerwriter->writeImage(*mFogOfWarImage, ostream); if (!result.success()) { - std::cerr << "Error: Unable to write fog: " << result.message() << " code " << result.status() << std::endl; + Log(Debug::Error) << "Error: Unable to write fog: " << result.message() << " code " << result.status(); return; } mFogOfWarImage->flipVertical(); diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index baf6cb822..98f8ce892 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -7,6 +7,8 @@ #include #include +#include + #include #include @@ -435,7 +437,7 @@ void NpcAnimation::updateNpcBase() if (bp) mHeadModel = "meshes\\" + bp->mModel; else - std::cerr << "Warning: Failed to load body part '" << mNpc->mHead << "'" << std::endl; + Log(Debug::Warning) << "Warning: Failed to load body part '" << mNpc->mHead << "'"; } mHairModel = ""; @@ -445,7 +447,7 @@ void NpcAnimation::updateNpcBase() if (bp) mHairModel = "meshes\\" + bp->mModel; else - std::cerr << "Warning: Failed to load body part '" << mNpc->mHair << "'" << std::endl; + Log(Debug::Warning) << "Warning: Failed to load body part '" << mNpc->mHair << "'"; } } @@ -758,7 +760,7 @@ bool NpcAnimation::addOrReplaceIndividualPart(ESM::PartReferenceType type, int g } catch (std::exception& e) { - std::cerr << "Error adding NPC part: " << e.what() << std::endl; + Log(Debug::Error) << "Error adding NPC part: " << e.what(); return false; } @@ -845,7 +847,7 @@ void NpcAnimation::addPartGroup(int group, int priority, const std::vectormFemale << "'" << std::endl; + Log(Debug::Warning) << "Warning: Failed to find body part '" << part->mFemale << "'"; } if(!bodypart && !part->mMale.empty()) { @@ -860,7 +862,7 @@ void NpcAnimation::addPartGroup(int group, int priority, const std::vectormMale << "'" << std::endl; + Log(Debug::Warning) << "Warning: Failed to find body part '" << part->mMale << "'"; } if(bodypart) diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index 03863000f..e17fe3191 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -22,6 +22,8 @@ #include +#include + #include #include #include @@ -709,7 +711,7 @@ namespace MWRender if (!found) { - std::cerr << "Wrong screenshot type: " << settingArgs[0] << "." << std::endl; + Log(Debug::Warning) << "Wrong screenshot type: " << settingArgs[0] << "."; return false; } } @@ -728,7 +730,7 @@ namespace MWRender if (mCamera->isVanityOrPreviewModeEnabled()) { - std::cerr << "Spherical screenshots are not allowed in preview mode." << std::endl; + Log(Debug::Warning) << "Spherical screenshots are not allowed in preview mode."; return false; } diff --git a/apps/openmw/mwrender/water.cpp b/apps/openmw/mwrender/water.cpp index 3c617f794..52832ad87 100644 --- a/apps/openmw/mwrender/water.cpp +++ b/apps/openmw/mwrender/water.cpp @@ -19,6 +19,8 @@ #include #include +#include + #include #include #include @@ -29,7 +31,6 @@ #include - #include #include @@ -193,16 +194,16 @@ osg::ref_ptr readPngImage (const std::string& file) boost::filesystem::ifstream inStream; inStream.open(file, std::ios_base::in | std::ios_base::binary); if (inStream.fail()) - std::cerr << "Error: Failed to open " << file << std::endl; + Log(Debug::Error) << "Error: Failed to open " << file; osgDB::ReaderWriter* reader = osgDB::Registry::instance()->getReaderWriterForExtension("png"); if (!reader) { - std::cerr << "Error: Failed to read " << file << ", no png readerwriter found" << std::endl; + Log(Debug::Error) << "Error: Failed to read " << file << ", no png readerwriter found"; return osg::ref_ptr(); } osgDB::ReaderWriter::ReadResult result = reader->readImage(inStream); if (!result.success()) - std::cerr << "Error: Failed to read " << file << ": " << result.message() << " code " << result.status() << std::endl; + Log(Debug::Error) << "Error: Failed to read " << file << ": " << result.message() << " code " << result.status(); return result.getImage(); } diff --git a/apps/openmw/mwscript/aiextensions.cpp b/apps/openmw/mwscript/aiextensions.cpp index c51a55b50..0bb94a134 100644 --- a/apps/openmw/mwscript/aiextensions.cpp +++ b/apps/openmw/mwscript/aiextensions.cpp @@ -1,7 +1,8 @@ #include "aiextensions.hpp" #include -#include + +#include #include #include @@ -50,7 +51,7 @@ namespace MWScript MWMechanics::AiActivate activatePackage(objectID); ptr.getClass().getCreatureStats (ptr).getAiSequence().stack(activatePackage, ptr); - std::cout << "AiActivate" << std::endl; + Log(Debug::Info) << "AiActivate"; } }; @@ -78,7 +79,7 @@ namespace MWScript MWMechanics::AiTravel travelPackage(x, y, z); ptr.getClass().getCreatureStats (ptr).getAiSequence().stack(travelPackage, ptr); - std::cout << "AiTravel: " << x << ", " << y << ", " << z << std::endl; + Log(Debug::Info) << "AiTravel: " << x << ", " << y << ", " << z; } }; @@ -112,8 +113,7 @@ namespace MWScript MWMechanics::AiEscort escortPackage(actorID, static_cast(duration), x, y, z); ptr.getClass().getCreatureStats (ptr).getAiSequence().stack(escortPackage, ptr); - std::cout << "AiEscort: " << x << ", " << y << ", " << z << ", " << duration - << std::endl; + Log(Debug::Info) << "AiEscort: " << x << ", " << y << ", " << z << ", " << duration; } }; @@ -155,8 +155,7 @@ namespace MWScript MWMechanics::AiEscort escortPackage(actorID, cellID, static_cast(duration), x, y, z); ptr.getClass().getCreatureStats (ptr).getAiSequence().stack(escortPackage, ptr); - std::cout << "AiEscort: " << x << ", " << y << ", " << z << ", " << duration - << std::endl; + Log(Debug::Info) << "AiEscort: " << x << ", " << y << ", " << z << ", " << duration; } }; @@ -316,8 +315,7 @@ namespace MWScript MWMechanics::AiFollow followPackage(actorID, duration, x, y ,z); ptr.getClass().getCreatureStats (ptr).getAiSequence().stack(followPackage, ptr); - std::cout << "AiFollow: " << actorID << ", " << x << ", " << y << ", " << z << ", " << duration - << std::endl; + Log(Debug::Info) << "AiFollow: " << actorID << ", " << x << ", " << y << ", " << z << ", " << duration; } }; @@ -353,8 +351,7 @@ namespace MWScript MWMechanics::AiFollow followPackage(actorID, cellID, duration, x, y ,z); ptr.getClass().getCreatureStats (ptr).getAiSequence().stack(followPackage, ptr); - std::cout << "AiFollow: " << actorID << ", " << x << ", " << y << ", " << z << ", " << duration - << std::endl; + Log(Debug::Info) << "AiFollow: " << actorID << ", " << x << ", " << y << ", " << z << ", " << duration; } }; diff --git a/apps/openmw/mwscript/containerextensions.cpp b/apps/openmw/mwscript/containerextensions.cpp index 0feadaa59..dd3e54a88 100644 --- a/apps/openmw/mwscript/containerextensions.cpp +++ b/apps/openmw/mwscript/containerextensions.cpp @@ -6,6 +6,8 @@ #include +#include + #include #include @@ -190,8 +192,8 @@ namespace MWScript if (it == invStore.end()) { it = ptr.getClass().getContainerStore (ptr).add (item, 1, ptr); - std::cerr << "Implicitly adding one " << item << " to container " - "to fulfil requirements of Equip instruction" << std::endl; + Log(Debug::Warning) << "Implicitly adding one " << item << " to container " + "to fulfil requirements of Equip instruction"; } if (ptr == MWMechanics::getPlayer()) diff --git a/apps/openmw/mwscript/dialogueextensions.cpp b/apps/openmw/mwscript/dialogueextensions.cpp index 4b6ddcf9f..135cb787e 100644 --- a/apps/openmw/mwscript/dialogueextensions.cpp +++ b/apps/openmw/mwscript/dialogueextensions.cpp @@ -1,10 +1,8 @@ -#include - #include "dialogueextensions.hpp" #include #include - +#include #include #include #include @@ -139,8 +137,8 @@ namespace MWScript if (!ptr.getClass().isActor()) { const std::string error = "Warning: \"forcegreeting\" command works only for actors."; - runtime.getContext().report (error); - std::cerr << error << std::endl; + runtime.getContext().report(error); + Log(Debug::Warning) << error; return; } diff --git a/apps/openmw/mwscript/globalscripts.cpp b/apps/openmw/mwscript/globalscripts.cpp index 6074a12d0..a52a4938a 100644 --- a/apps/openmw/mwscript/globalscripts.cpp +++ b/apps/openmw/mwscript/globalscripts.cpp @@ -1,8 +1,8 @@ #include "globalscripts.hpp" #include -#include +#include #include #include #include @@ -113,9 +113,9 @@ namespace MWScript } catch (const std::exception& exception) { - std::cerr + Log(Debug::Error) << "Failed to add start script " << *iter << " because an exception has " - << "been thrown: " << exception.what() << std::endl; + << "been thrown: " << exception.what(); } } } @@ -169,10 +169,9 @@ namespace MWScript } catch (const std::exception& exception) { - std::cerr + Log(Debug::Error) << "Failed to add start script " << script.mId - << " because an exception has been thrown: " << exception.what() - << std::endl; + << " because an exception has been thrown: " << exception.what(); return true; } diff --git a/apps/openmw/mwscript/locals.cpp b/apps/openmw/mwscript/locals.cpp index 64f3058eb..4c5573168 100644 --- a/apps/openmw/mwscript/locals.cpp +++ b/apps/openmw/mwscript/locals.cpp @@ -3,7 +3,7 @@ #include #include #include - +#include #include #include @@ -229,10 +229,10 @@ namespace MWScript } catch (std::exception& e) { - std::cerr << "Failed to read local variable state for script '" - << script << "' (legacy format): " << e.what() - << "\nNum shorts: " << numshorts << " / " << mShorts.size() - << " Num longs: " << numlongs << " / " << mLongs.size() << std::endl; + Log(Debug::Error) << "Failed to read local variable state for script '" + << script << "' (legacy format): " << e.what() + << "\nNum shorts: " << numshorts << " / " << mShorts.size() + << " Num longs: " << numlongs << " / " << mLongs.size(); } } else diff --git a/apps/openmw/mwscript/scriptmanagerimp.cpp b/apps/openmw/mwscript/scriptmanagerimp.cpp index 7c1f9bf4d..80496d6db 100644 --- a/apps/openmw/mwscript/scriptmanagerimp.cpp +++ b/apps/openmw/mwscript/scriptmanagerimp.cpp @@ -1,11 +1,12 @@ #include "scriptmanagerimp.hpp" #include -#include #include #include #include +#include + #include #include @@ -65,14 +66,14 @@ namespace MWScript } catch (const std::exception& error) { - std::cerr << "Error: An exception has been thrown: " << error.what() << std::endl; + Log(Debug::Error) << "Error: An exception has been thrown: " << error.what(); Success = false; } if (!Success) { - std::cerr - << "Warning: compiling failed: " << name << std::endl; + Log(Debug::Warning) + << "Warning: compiling failed: " << name; } if (Success) @@ -121,8 +122,8 @@ namespace MWScript } catch (const std::exception& e) { - std::cerr << "Execution of script " << name << " failed:" << std::endl; - std::cerr << e.what() << std::endl; + Log(Debug::Error) << "Execution of script " << name << " failed:"; + Log(Debug::Error) << e.what(); iter->second.first.clear(); // don't execute again. } diff --git a/apps/openmw/mwscript/statsextensions.cpp b/apps/openmw/mwscript/statsextensions.cpp index fadc99b66..2ff5035ae 100644 --- a/apps/openmw/mwscript/statsextensions.cpp +++ b/apps/openmw/mwscript/statsextensions.cpp @@ -1,6 +1,5 @@ #include "statsextensions.hpp" -#include #include #include @@ -9,7 +8,7 @@ #include #include - +#include #include #include #include @@ -246,9 +245,10 @@ namespace MWScript if (R()(runtime, false, true).isEmpty()) { - std::cerr + Log(Debug::Warning) << "Warning: Compensating for broken script in Morrowind.esm by " - << "ignoring remote access to dagoth_ur_1" << std::endl; + << "ignoring remote access to dagoth_ur_1"; + return; } } diff --git a/apps/openmw/mwscript/transformationextensions.cpp b/apps/openmw/mwscript/transformationextensions.cpp index 611199f72..8f0c72519 100644 --- a/apps/openmw/mwscript/transformationextensions.cpp +++ b/apps/openmw/mwscript/transformationextensions.cpp @@ -1,4 +1,4 @@ -#include +#include #include @@ -317,7 +317,7 @@ namespace MWScript { std::string error = "Warning: PositionCell: unknown interior cell (" + cellID + "), moving to exterior instead"; runtime.getContext().report (error); - std::cerr << error << std::endl; + Log(Debug::Warning) << error; } } if(store) @@ -429,7 +429,7 @@ namespace MWScript if(!cell) { runtime.getContext().report ("unknown cell (" + cellID + ")"); - std::cerr << "unknown cell (" << cellID << ")\n"; + Log(Debug::Error) << "Error: unknown cell (" << cellID << ")"; } } if(store) diff --git a/apps/openmw/mwsound/ffmpeg_decoder.cpp b/apps/openmw/mwsound/ffmpeg_decoder.cpp index f458c0a97..7dffd685a 100644 --- a/apps/openmw/mwsound/ffmpeg_decoder.cpp +++ b/apps/openmw/mwsound/ffmpeg_decoder.cpp @@ -3,9 +3,9 @@ #include #include -#include #include +#include #include namespace MWSound @@ -28,7 +28,7 @@ int FFmpeg_Decoder::readPacket(void *user_data, uint8_t *buf, int buf_size) int FFmpeg_Decoder::writePacket(void *, uint8_t *, int) { - std::cerr<< "can't write to read-only stream" <codec->channels, (*mStream)->codec->channel_layout); - std::cerr<< "Unsupported channel layout: "<codec->channels == 1) { @@ -385,7 +385,7 @@ size_t FFmpeg_Decoder::read(char *buffer, size_t bytes) { if(!mStream) { - std::cerr<< "No audio stream" < &output) { if(!mStream) { - std::cerr<< "No audio stream" < #include -#include #include #include #include @@ -8,6 +7,7 @@ #include +#include #include #include @@ -44,8 +44,7 @@ ALCenum checkALCError(ALCdevice *device, const char *func, int line) { ALCenum err = alcGetError(device); if(err != ALC_NO_ERROR) - std::cerr<< ">>>>>>>>> ALC error "<>>>>>>>> AL error "<getInfo(&mSampleRate, &chans, &type); mFormat = getALFormat(chans, type); } - catch(std::exception &e) { - std::cerr<< "Failed to get stream info: "<getName()<<"\"" <getName() << "\""; mIsFinished = true; } return !mIsFinished; @@ -593,17 +591,18 @@ bool OpenAL_Output::init(const std::string &devname, const std::string &hrtfname { deinit(); - std::cout<< "Initializing OpenAL..." < OpenAL_Output::loadSound(const std::string &fname } catch(std::exception &e) { - std::cerr<< "Failed to load audio from "<getIsLooping()) - std::cout <<"Warning: cannot loop stream \""<getName()<<"\""<< std::endl; + Log(Debug::Warning) << "Warning: cannot loop stream \"" << decoder->getName() << "\""; + initCommon2D(source, sound->getPosition(), sound->getRealVolume(), sound->getPitch(), false, sound->getUseEnv()); if(getALError() != AL_NO_ERROR) @@ -1266,13 +1266,14 @@ bool OpenAL_Output::streamSound3D(DecoderPtr decoder, Stream *sound, bool getLou { if(mFreeSources.empty()) { - std::cerr<< "No free sources!" <getIsLooping()) - std::cout <<"Warning: cannot loop stream \""<getName()<<"\""<< std::endl; + Log(Debug::Warning) << "Warning: cannot loop stream \"" << decoder->getName() << "\""; + initCommon3D(source, sound->getPosition(), sound->getMinDistance(), sound->getMaxDistance(), sound->getRealVolume(), sound->getPitch(), false, sound->getUseEnv()); if(getALError() != AL_NO_ERROR) diff --git a/apps/openmw/mwsound/soundmanagerimp.cpp b/apps/openmw/mwsound/soundmanagerimp.cpp index 8c71ab61b..d6dc2ba99 100644 --- a/apps/openmw/mwsound/soundmanagerimp.cpp +++ b/apps/openmw/mwsound/soundmanagerimp.cpp @@ -1,6 +1,5 @@ #include "soundmanagerimp.hpp" -#include #include #include #include @@ -8,7 +7,7 @@ #include #include - +#include #include #include "../mwbase/environment.hpp" @@ -81,7 +80,7 @@ namespace MWSound if(!useSound) { - std::cout<< "Sound disabled." <init(devname, hrtfname, hrtfmode)) { - std::cerr<< "Failed to initialize audio output, sound disabled" < names = mOutput->enumerate(); - std::cout <<"Enumerated output devices:\n"; + std::stringstream stream; + + stream << "Enumerated output devices:\n"; for(const std::string &name : names) - std::cout <<" "<enumerateHrtf(); if(!names.empty()) { - std::cout<< "Enumerated HRTF names:\n"; + stream << "Enumerated HRTF names:\n"; for(const std::string &name : names) - std::cout <<" "<isInitialized()) return; - std::cout <<"Playing "< + #include #include #include @@ -157,7 +159,7 @@ void MWState::StateManager::newGame (bool bypass) std::stringstream error; error << "Failed to start new game: " << e.what(); - std::cerr << error.str() << std::endl; + Log(Debug::Error) << error.str(); cleanup (true); MWBase::Environment::get().getWindowManager()->pushGuiMode (MWGui::GM_MainMenu); @@ -283,7 +285,7 @@ void MWState::StateManager::saveGame (const std::string& description, const Slot // Ensure we have written the number of records that was estimated if (writer.getRecordCount() != recordCount+1) // 1 extra for TES3 record - std::cerr << "Warning: number of written savegame records does not match. Estimated: " << recordCount+1 << ", written: " << writer.getRecordCount() << std::endl; + Log(Debug::Warning) << "Warning: number of written savegame records does not match. Estimated: " << recordCount+1 << ", written: " << writer.getRecordCount(); writer.close(); @@ -305,7 +307,7 @@ void MWState::StateManager::saveGame (const std::string& description, const Slot std::stringstream error; error << "Failed to save game: " << e.what(); - std::cerr << error.str() << std::endl; + Log(Debug::Error) << error.str(); std::vector buttons; buttons.push_back("#{sOk}"); @@ -483,7 +485,7 @@ void MWState::StateManager::loadGame (const Character *character, const std::str default: // ignore invalid records - std::cerr << "Warning: Ignoring unknown record: " << n.toString() << std::endl; + Log(Debug::Warning) << "Warning: Ignoring unknown record: " << n.toString(); reader.skipRecord(); } int progressPercent = static_cast(float(reader.getFileOffset())/total*100); @@ -549,7 +551,7 @@ void MWState::StateManager::loadGame (const Character *character, const std::str std::stringstream error; error << "Failed to load saved game: " << e.what(); - std::cerr << error.str() << std::endl; + Log(Debug::Error) << error.str(); cleanup (true); MWBase::Environment::get().getWindowManager()->pushGuiMode (MWGui::GM_MainMenu); @@ -625,7 +627,7 @@ bool MWState::StateManager::verifyProfile(const ESM::SavedGame& profile) const if (std::find(selectedContentFiles.begin(), selectedContentFiles.end(), *it) == selectedContentFiles.end()) { - std::cerr << "Warning: Savegame dependency " << *it << " is missing." << std::endl; + Log(Debug::Warning) << "Warning: Savegame dependency " << *it << " is missing."; notFound = true; } } @@ -653,7 +655,7 @@ void MWState::StateManager::writeScreenshot(std::vector &imageData) const osgDB::ReaderWriter* readerwriter = osgDB::Registry::instance()->getReaderWriterForExtension("jpg"); if (!readerwriter) { - std::cerr << "Error: Unable to write screenshot, can't find a jpg ReaderWriter" << std::endl; + Log(Debug::Error) << "Error: Unable to write screenshot, can't find a jpg ReaderWriter"; return; } @@ -661,7 +663,7 @@ void MWState::StateManager::writeScreenshot(std::vector &imageData) const osgDB::ReaderWriter::WriteResult result = readerwriter->writeImage(*screenshot, ostream); if (!result.success()) { - std::cerr << "Error: Unable to write screenshot: " << result.message() << " code " << result.status() << std::endl; + Log(Debug::Error) << "Error: Unable to write screenshot: " << result.message() << " code " << result.status(); return; } diff --git a/apps/openmw/mwworld/cellpreloader.cpp b/apps/openmw/mwworld/cellpreloader.cpp index 700b91b37..9163f1f2e 100644 --- a/apps/openmw/mwworld/cellpreloader.cpp +++ b/apps/openmw/mwworld/cellpreloader.cpp @@ -1,7 +1,6 @@ #include "cellpreloader.hpp" -#include - +#include #include #include #include @@ -229,12 +228,12 @@ namespace MWWorld { if (!mWorkQueue) { - std::cerr << "Error: can't preload, no work queue set " << std::endl; + Log(Debug::Error) << "Error: can't preload, no work queue set"; return; } if (cell->getState() == CellStore::State_Unloaded) { - std::cerr << "Error: can't preload objects for unloaded cell" << std::endl; + Log(Debug::Error) << "Error: can't preload objects for unloaded cell"; return; } diff --git a/apps/openmw/mwworld/cells.cpp b/apps/openmw/mwworld/cells.cpp index 752659eb6..5cac12b9c 100644 --- a/apps/openmw/mwworld/cells.cpp +++ b/apps/openmw/mwworld/cells.cpp @@ -1,7 +1,6 @@ #include "cells.hpp" -#include - +#include #include #include #include @@ -350,7 +349,7 @@ bool MWWorld::Cells::readRecord (ESM::ESMReader& reader, uint32_t type, catch (...) { // silently drop cells that don't exist anymore - std::cerr << "Warning: Dropping state for cell " << state.mId.mWorldspace << " (cell no longer exists)" << std::endl; + Log(Debug::Warning) << "Warning: Dropping state for cell " << state.mId.mWorldspace << " (cell no longer exists)"; reader.skipRecord(); return true; } diff --git a/apps/openmw/mwworld/cellstore.cpp b/apps/openmw/mwworld/cellstore.cpp index fc3c2e245..40e904ec2 100644 --- a/apps/openmw/mwworld/cellstore.cpp +++ b/apps/openmw/mwworld/cellstore.cpp @@ -1,8 +1,9 @@ #include "cellstore.hpp" -#include #include +#include + #include #include #include @@ -138,7 +139,7 @@ namespace return; } - std::cerr << "Warning: Dropping reference to " << state.mRef.mRefID << " (invalid content file link)" << std::endl; + Log(Debug::Warning) << "Warning: Dropping reference to " << state.mRef.mRefID << " (invalid content file link)"; return; } @@ -196,9 +197,9 @@ namespace MWWorld } else { - std::cerr + Log(Debug::Warning) << "Warning: could not resolve cell reference '" << ref.mRefID << "'" - << " (dropping reference)" << std::endl; + << " (dropping reference)"; } } @@ -497,7 +498,7 @@ namespace MWWorld } catch (std::exception& e) { - std::cerr << "An error occurred listing references for cell " << getCell()->getDescription() << ": " << e.what() << std::endl; + Log(Debug::Error) << "An error occurred listing references for cell " << getCell()->getDescription() << ": " << e.what(); } } @@ -553,7 +554,7 @@ namespace MWWorld } catch (std::exception& e) { - std::cerr << "An error occurred loading references for cell " << getCell()->getDescription() << ": " << e.what() << std::endl; + Log(Debug::Error) << "An error occurred loading references for cell " << getCell()->getDescription() << ": " << e.what(); } } @@ -659,11 +660,10 @@ namespace MWWorld case ESM::REC_WEAP: mWeapons.load(ref, deleted, store); break; case ESM::REC_BODY: mBodyParts.load(ref, deleted, store); break; - case 0: std::cerr << "Cell reference '" + ref.mRefID + "' not found!\n"; return; + case 0: Log(Debug::Error) << "Cell reference '" + ref.mRefID + "' not found!"; return; default: - std::cerr - << "Error: Ignoring reference '" << ref.mRefID << "' of unhandled type\n"; + Log(Debug::Error) << "Error: Ignoring reference '" << ref.mRefID << "' of unhandled type"; return; } @@ -756,7 +756,7 @@ namespace MWWorld int type = MWBase::Environment::get().getWorld()->getStore().find(cref.mRefID); if (type == 0) { - std::cerr << "Dropping reference to '" << cref.mRefID << "' (object no longer exists)" << std::endl; + Log(Debug::Warning) << "Dropping reference to '" << cref.mRefID << "' (object no longer exists)"; reader.skipHSubUntil("OBJE"); continue; } @@ -892,7 +892,7 @@ namespace MWWorld if (!visitor.mFound) { - std::cerr << "Warning: Dropping moved ref tag for " << refnum.mIndex << " (moved object no longer exists)" << std::endl; + Log(Debug::Warning) << "Warning: Dropping moved ref tag for " << refnum.mIndex << " (moved object no longer exists)"; continue; } @@ -902,8 +902,8 @@ namespace MWWorld if (otherCell == NULL) { - std::cerr << "Warning: Dropping moved ref tag for " << movedRef->mRef.getRefId() - << " (target cell " << movedTo.mWorldspace << " no longer exists). Reference moved back to its original location." << std::endl; + Log(Debug::Warning) << "Warning: Dropping moved ref tag for " << movedRef->mRef.getRefId() + << " (target cell " << movedTo.mWorldspace << " no longer exists). Reference moved back to its original location."; // Note by dropping tag the object will automatically re-appear in its original cell, though potentially at inapproriate coordinates. // Restore original coordinates: movedRef->mData.setPosition(movedRef->mRef.getPosition()); @@ -913,7 +913,7 @@ namespace MWWorld if (otherCell == this) { // Should never happen unless someone's tampering with files. - std::cerr << "Found invalid moved ref, ignoring" << std::endl; + Log(Debug::Warning) << "Found invalid moved ref, ignoring"; continue; } diff --git a/apps/openmw/mwworld/containerstore.cpp b/apps/openmw/mwworld/containerstore.cpp index 6c369a154..8fa16ff51 100644 --- a/apps/openmw/mwworld/containerstore.cpp +++ b/apps/openmw/mwworld/containerstore.cpp @@ -4,6 +4,7 @@ #include #include +#include #include #include "../mwbase/environment.hpp" @@ -502,7 +503,7 @@ void MWWorld::ContainerStore::addInitialItem (const std::string& id, const std:: } catch (const std::exception& e) { - std::cerr << "Warning: MWWorld::ContainerStore::addInitialItem: " << e.what() << std::endl; + Log(Debug::Warning) << "Warning: MWWorld::ContainerStore::addInitialItem: " << e.what(); } } @@ -826,10 +827,10 @@ void MWWorld::ContainerStore::readState (const ESM::InventoryState& inventory) case ESM::REC_WEAP: readEquipmentState (getState (weapons, state), thisIndex, inventory); break; case ESM::REC_LIGH: readEquipmentState (getState (lights, state), thisIndex, inventory); break; case 0: - std::cerr << "Dropping inventory reference to '" << state.mRef.mRefID << "' (object no longer exists)" << std::endl; + Log(Debug::Warning) << "Dropping inventory reference to '" << state.mRef.mRefID << "' (object no longer exists)"; break; default: - std::cerr << "Warning: Invalid item type in inventory state, refid " << state.mRef.mRefID << std::endl; + Log(Debug::Warning) << "Warning: Invalid item type in inventory state, refid " << state.mRef.mRefID; break; } } diff --git a/apps/openmw/mwworld/contentloader.hpp b/apps/openmw/mwworld/contentloader.hpp index 0f2d807aa..2069a78fc 100644 --- a/apps/openmw/mwworld/contentloader.hpp +++ b/apps/openmw/mwworld/contentloader.hpp @@ -2,10 +2,10 @@ #define CONTENTLOADER_HPP #include -#include #include #include +#include #include "components/loadinglistener/loadinglistener.hpp" namespace MWWorld @@ -24,8 +24,8 @@ struct ContentLoader virtual void load(const boost::filesystem::path& filepath, int& index) { - std::cout << "Loading content file " << filepath.string() << std::endl; - mListener.setLabel(MyGUI::TextIterator::toTagsString(filepath.string())); + Log(Debug::Info) << "Loading content file " << filepath.string(); + mListener.setLabel(MyGUI::TextIterator::toTagsString(filepath.string())); } protected: diff --git a/apps/openmw/mwworld/esmstore.cpp b/apps/openmw/mwworld/esmstore.cpp index ac5608b8e..01d8e4b82 100644 --- a/apps/openmw/mwworld/esmstore.cpp +++ b/apps/openmw/mwworld/esmstore.cpp @@ -1,12 +1,11 @@ #include "esmstore.hpp" #include -#include #include +#include #include - #include #include @@ -84,7 +83,7 @@ void ESMStore::load(ESM::ESMReader &esm, Loading::Listener* listener) } else { - std::cerr << "error: info record without dialog" << std::endl; + Log(Debug::Error) << "Error: info record without dialog"; esm.skipRecord(); } } else if (n.intval == ESM::REC_MGEF) { @@ -170,7 +169,7 @@ void ESMStore::validate() const ESM::Faction *fact = mFactions.search(npcFaction); if (!fact) { - std::cerr << "NPC '" << npc.mId << "' (" << npc.mName << ") has nonexistent faction '" << npc.mFaction << "', ignoring it." << std::endl; + Log(Debug::Verbose) << "NPC '" << npc.mId << "' (" << npc.mName << ") has nonexistent faction '" << npc.mFaction << "', ignoring it."; npc.mFaction = ""; npc.mNpdt.mRank = -1; changed = true; @@ -183,7 +182,7 @@ void ESMStore::validate() const ESM::Class *cls = mClasses.search(npcClass); if (!cls) { - std::cerr << "NPC '" << npc.mId << "' (" << npc.mName << ") has nonexistent class '" << npc.mClass << "', using '" << defaultCls << "' class as replacement." << std::endl; + Log(Debug::Verbose) << "NPC '" << npc.mId << "' (" << npc.mName << ") has nonexistent class '" << npc.mClass << "', using '" << defaultCls << "' class as replacement."; npc.mClass = defaultCls; changed = true; } diff --git a/apps/openmw/mwworld/inventorystore.cpp b/apps/openmw/mwworld/inventorystore.cpp index ba3ea2381..6cfffcde6 100644 --- a/apps/openmw/mwworld/inventorystore.cpp +++ b/apps/openmw/mwworld/inventorystore.cpp @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -895,7 +896,7 @@ void MWWorld::InventoryStore::updateRechargingItems() enchantmentId); if (!enchantment) { - std::cerr << "Warning: Can't find enchantment '" << enchantmentId << "' on item " << it->getCellRef().getRefId() << std::endl; + Log(Debug::Warning) << "Warning: Can't find enchantment '" << enchantmentId << "' on item " << it->getCellRef().getRefId(); continue; } diff --git a/apps/openmw/mwworld/livecellref.cpp b/apps/openmw/mwworld/livecellref.cpp index b8178f774..9cf8a0fe0 100644 --- a/apps/openmw/mwworld/livecellref.cpp +++ b/apps/openmw/mwworld/livecellref.cpp @@ -1,7 +1,6 @@ #include "livecellref.hpp" -#include - +#include #include #include "../mwbase/environment.hpp" @@ -38,10 +37,9 @@ void MWWorld::LiveCellRefBase::loadImp (const ESM::ObjectState& state) } catch (const std::exception& exception) { - std::cerr + Log(Debug::Error) << "Error: failed to load state for local script " << scriptId - << " because an exception has been thrown: " << exception.what() - << std::endl; + << " because an exception has been thrown: " << exception.what(); } } } @@ -51,7 +49,7 @@ void MWWorld::LiveCellRefBase::loadImp (const ESM::ObjectState& state) if (!mRef.getSoul().empty() && !MWBase::Environment::get().getWorld()->getStore().get().search(mRef.getSoul())) { - std::cerr << "Soul '" << mRef.getSoul() << "' not found, removing the soul from soul gem" << std::endl; + Log(Debug::Warning) << "Soul '" << mRef.getSoul() << "' not found, removing the soul from soul gem"; mRef.setSoul(std::string()); } } diff --git a/apps/openmw/mwworld/localscripts.cpp b/apps/openmw/mwworld/localscripts.cpp index 4ed83bf11..ff47d3e56 100644 --- a/apps/openmw/mwworld/localscripts.cpp +++ b/apps/openmw/mwworld/localscripts.cpp @@ -1,14 +1,12 @@ #include "localscripts.hpp" -#include +#include #include "esmstore.hpp" #include "cellstore.hpp" - #include "class.hpp" #include "containerstore.hpp" - namespace { @@ -93,7 +91,7 @@ void MWWorld::LocalScripts::add (const std::string& scriptName, const Ptr& ptr) for (std::list >::iterator iter = mScripts.begin(); iter!=mScripts.end(); ++iter) if (iter->second==ptr) { - std::cerr << "Error: tried to add local script twice for " << ptr.getCellRef().getRefId() << std::endl; + Log(Debug::Warning) << "Error: tried to add local script twice for " << ptr.getCellRef().getRefId(); remove(ptr); break; } @@ -102,15 +100,15 @@ void MWWorld::LocalScripts::add (const std::string& scriptName, const Ptr& ptr) } catch (const std::exception& exception) { - std::cerr + Log(Debug::Error) << "failed to add local script " << scriptName - << " because an exception has been thrown: " << exception.what() << std::endl; + << " because an exception has been thrown: " << exception.what(); } } else - std::cerr + Log(Debug::Warning) << "failed to add local script " << scriptName - << " because the script does not exist." << std::endl; + << " because the script does not exist."; } void MWWorld::LocalScripts::addCell (CellStore *cell) diff --git a/apps/openmw/mwworld/player.cpp b/apps/openmw/mwworld/player.cpp index 5439447fd..44b78336d 100644 --- a/apps/openmw/mwworld/player.cpp +++ b/apps/openmw/mwworld/player.cpp @@ -1,7 +1,8 @@ #include "player.hpp" #include -#include + +#include #include #include @@ -364,7 +365,7 @@ namespace MWWorld if (!player.mObject.mEnabled) { - std::cerr << "Warning: Savegame attempted to disable the player." << std::endl; + Log(Debug::Warning) << "Warning: Savegame attempted to disable the player."; player.mObject.mEnabled = true; } @@ -391,7 +392,7 @@ namespace MWWorld } catch (...) { - std::cerr << "Warning: Player cell '" << player.mCellId.mWorldspace << "' no longer exists" << std::endl; + Log(Debug::Warning) << "Warning: Player cell '" << player.mCellId.mWorldspace << "' no longer exists"; // Cell no longer exists. The loader will have to choose a default cell. mCellStore = NULL; } diff --git a/apps/openmw/mwworld/projectilemanager.cpp b/apps/openmw/mwworld/projectilemanager.cpp index a4a22ea4a..f150ff0ba 100644 --- a/apps/openmw/mwworld/projectilemanager.cpp +++ b/apps/openmw/mwworld/projectilemanager.cpp @@ -1,11 +1,12 @@ #include "projectilemanager.hpp" #include -#include #include #include +#include + #include #include @@ -647,7 +648,7 @@ namespace MWWorld } catch(...) { - std::cerr << "Warning: Failed to recreate magic projectile from saved data (id \"" << state.mSpellId << "\" no longer exists?)" << std::endl; + Log(Debug::Warning) << "Warning: Failed to recreate magic projectile from saved data (id \"" << state.mSpellId << "\" no longer exists?)"; return true; } diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index 2c2d401d1..ed6dde310 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -1,8 +1,8 @@ #include "scene.hpp" #include -#include +#include #include #include #include @@ -56,7 +56,7 @@ namespace { if (ptr.getRefData().getBaseNode() || physics.getActor(ptr)) { - std::cerr << "Warning: Tried to add " << ptr.getCellRef().getRefId() << " to the scene twice" << std::endl; + Log(Debug::Warning) << "Warning: Tried to add " << ptr.getCellRef().getRefId() << " to the scene twice"; return; } @@ -160,7 +160,7 @@ namespace catch (const std::exception& e) { std::string error ("failed to render '" + ptr.getCellRef().getRefId() + "': "); - std::cerr << error + e.what() << std::endl; + Log(Debug::Error) << error + e.what(); } } @@ -232,7 +232,7 @@ namespace MWWorld void Scene::unloadCell (CellStoreCollection::iterator iter) { - std::cout << "Unloading cell\n"; + Log(Debug::Info) << "Unloading cell " << (*iter)->getCell()->getDescription(); ListAndResetObjectsVisitor visitor; (*iter)->forEach(visitor); @@ -270,7 +270,7 @@ namespace MWWorld if(result.second) { - std::cout << "Loading cell " << cell->getCell()->getDescription() << std::endl; + Log(Debug::Info) << "Loading cell " << cell->getCell()->getDescription(); float verts = ESM::Land::LAND_SIZE; float worldsize = ESM::Land::REAL_SIZE; @@ -546,7 +546,7 @@ namespace MWWorld return; } - std::cout << "Changing to interior\n"; + Log(Debug::Info) << "Changing to interior"; // unload CellStoreCollection::iterator active = mActiveCells.begin(); @@ -624,7 +624,7 @@ namespace MWWorld } catch (std::exception& e) { - std::cerr << "failed to render '" << ptr.getCellRef().getRefId() << "': " << e.what() << std::endl; + Log(Debug::Error) << "failed to render '" << ptr.getCellRef().getRefId() << "': " << e.what(); } } diff --git a/apps/openmw/mwworld/store.cpp b/apps/openmw/mwworld/store.cpp index 6f0a1b49f..2ac78bb85 100644 --- a/apps/openmw/mwworld/store.cpp +++ b/apps/openmw/mwworld/store.cpp @@ -1,5 +1,7 @@ #include "store.hpp" +#include + #include #include @@ -8,7 +10,6 @@ #include #include -#include namespace { @@ -692,7 +693,7 @@ namespace MWWorld if (it_lease != wipecell->mLeasedRefs.end()) wipecell->mLeasedRefs.erase(it_lease); else - std::cerr << "Error: can't find " << it->mRefNum.mIndex << " " << it->mRefNum.mContentFile << " in leasedRefs " << std::endl; + Log(Debug::Error) << "Error: can't find " << it->mRefNum.mIndex << " " << it->mRefNum.mContentFile << " in leasedRefs"; } *itold = *it; } diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index f4c2a75f3..3e4f3ccd0 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -3,6 +3,8 @@ #include #include +#include + #include #include #include @@ -1794,7 +1796,7 @@ namespace MWWorld } catch (std::exception& e) { - std::cerr << "Error updating window manager: " << e.what() << std::endl; + Log(Debug::Error) << "Error updating window manager: " << e.what(); } } @@ -3075,7 +3077,7 @@ namespace MWWorld if ( closestMarker.isEmpty() ) { - std::cerr << "Failed to teleport: no closest marker found" << std::endl; + Log(Debug::Warning) << "Failed to teleport: no closest marker found"; return; } @@ -3250,19 +3252,19 @@ namespace MWWorld MWWorld::ConstPtr prisonMarker = getClosestMarker( ptr, "prisonmarker" ); if ( prisonMarker.isEmpty() ) { - std::cerr << "Failed to confiscate items: no closest prison marker found." << std::endl; + Log(Debug::Warning) << "Failed to confiscate items: no closest prison marker found."; return; } std::string prisonName = prisonMarker.getCellRef().getDestCell(); if ( prisonName.empty() ) { - std::cerr << "Failed to confiscate items: prison marker not linked to prison interior" << std::endl; + Log(Debug::Warning) << "Failed to confiscate items: prison marker not linked to prison interior"; return; } MWWorld::CellStore *prison = getInterior( prisonName ); if ( !prison ) { - std::cerr << "Failed to confiscate items: failed to load cell " << prisonName << std::endl; + Log(Debug::Warning) << "Failed to confiscate items: failed to load cell " << prisonName; return; } @@ -3272,7 +3274,7 @@ namespace MWWorld MWBase::Environment::get().getMechanicsManager()->confiscateStolenItems(ptr, closestChest); } else - std::cerr << "Failed to confiscate items: no stolen_goods container found" << std::endl; + Log(Debug::Warning) << "Failed to confiscate items: no stolen_goods container found"; } void World::goToJail()