diff --git a/components/crashcatcher/crashcatcher.cpp b/components/crashcatcher/crashcatcher.cpp index f7b8717a6b..04b239a7fa 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 bfd7d1196e..1ea18aa9b7 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 1f7c2b964d..4b9c6b0734 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 ddd49f8df9..83315a5b8f 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 9ef3d3964a..d7e0a6ee17 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 19246c4c45..474c2b4234 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 0f5b175025..f77e662765 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 7c3956a293..333ec5ced8 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 93db6834d0..98e25fcc86 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 080739bc1d..790df7fa84 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 515c6c7d58..3c6226d9ce 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 485a87ba7f..ddd7ca342d 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 a3b70eac97..6c53a96998 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 cab2e98807..0893db72ff 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 44134fd238..f970b7f3e5 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 5857a39872..3198e995c5 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 62360b9d64..03e836a0fd 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 000a833cf7..c1d71ee008 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 db8d99ab4e..8edb3d7657 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 7f148cf5e3..ee30f1c85c 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 94ae1f234e..58ed9a27cf 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 7e5646ecb1..42ea311337 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 2cd1ec806d..37e8563e12 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 1747c9b941..1560b74b3e 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 dd89d10724..c2963be861 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 15a222d313..66e5dfc045 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 5efd1b86ea..28f4300c29 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 9b3876d6c8..cbd950ea3b 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 8af0bc5ed8..d4ab00381b 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 9738e2a17c..ce4ff020ef 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 a22e785cd2..80e639f350 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 a3b0ae28ab..2ea494ebd0 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());