From 8cf75bb3c54dc8547273a67fc186b364207879d7 Mon Sep 17 00:00:00 2001 From: Oliver Hamlet Date: Thu, 2 Feb 2017 18:26:00 +0000 Subject: [PATCH] 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. --- src/gui/state/loot_paths.cpp | 4 ++++ src/gui/state/loot_paths.h | 1 + src/gui/state/loot_state.cpp | 7 ++++--- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/gui/state/loot_paths.cpp b/src/gui/state/loot_paths.cpp index 1a232ea9..d849b46e 100644 --- a/src/gui/state/loot_paths.cpp +++ b/src/gui/state/loot_paths.cpp @@ -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("")); diff --git a/src/gui/state/loot_paths.h b/src/gui/state/loot_paths.h index 38a08715..9f560331 100644 --- a/src/gui/state/loot_paths.h +++ b/src/gui/state/loot_paths.h @@ -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". diff --git a/src/gui/state/loot_state.cpp b/src/gui/state/loot_state.cpp index c9ff8363..d635295c 100644 --- a/src/gui/state/loot_state.cpp +++ b/src/gui/state/loot_state.cpp @@ -36,9 +36,7 @@ #include #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); } }