From c7a5548475f3495d6e1d711e943f4ebbbbf9dcc3 Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Tue, 14 Aug 2018 20:01:09 +0400 Subject: [PATCH] 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; } }