Use new API logging functions in GUI

API logs need to be written to a different file, which isn't ideal in
some respects, but is the easiest solution, and makes it clearer where
content is from.
This commit is contained in:
Oliver Hamlet
2017-02-06 18:03:17 +00:00
parent f353cc7bda
commit 8cf75bb3c5
3 changed files with 9 additions and 3 deletions
+4
View File
@@ -66,6 +66,10 @@ boost::filesystem::path LootPaths::getLogPath() {
return lootDataPath_ / "LOOTDebugLog.txt";
}
boost::filesystem::path LootPaths::getApiLogPath() {
return lootDataPath_ / "LOOTAPIDebugLog.txt";
}
void LootPaths::initialise(const std::string& lootDataPath) {
// Set the locale to get UTF-8 conversions working correctly.
std::locale::global(boost::locale::generator().generate(""));
+1
View File
@@ -36,6 +36,7 @@ public:
static boost::filesystem::path getLootDataPath();
static boost::filesystem::path getSettingsPath();
static boost::filesystem::path getLogPath();
static boost::filesystem::path getApiLogPath();
// Sets the app path to the current path, and the data path to the given
// path or (if it is an empty string), local app data path / "LOOT".
+4 -3
View File
@@ -36,9 +36,7 @@
#include <boost/log/utility/setup/file.hpp>
#include "gui/state/loot_paths.h"
#include "loot/exception/game_detection_error.h"
#include "loot/language.h"
#include "loot/loot_version.h"
#include "loot/api.h"
#include "loot/windows_encoding_converters.h"
#ifdef _WIN32
@@ -152,6 +150,7 @@ void LootState::init(const std::string& cmdLineGame) {
)
);
boost::log::add_common_attributes();
SetLogFile(LootPaths::getApiLogPath().string());
enableDebugLogging(isDebugLoggingEnabled());
// Log some useful info.
@@ -282,8 +281,10 @@ void LootState::selectGame(std::string preferredGame) {
void LootState::enableDebugLogging(bool enable) {
if (enable) {
boost::log::core::get()->reset_filter();
SetLoggingVerbosity(LogVerbosity::trace);
} else {
boost::log::core::get()->set_filter(boost::log::trivial::severity >= boost::log::trivial::warning);
SetLoggingVerbosity(LogVerbosity::warning);
}
}