Adjust messages logged on game handle creation

This commit is contained in:
Oliver Hamlet
2022-12-13 20:51:45 +00:00
parent f5811808fa
commit 3f7e2b48f3
3 changed files with 35 additions and 16 deletions
+28 -2
View File
@@ -32,6 +32,31 @@
namespace fs = std::filesystem;
namespace loot {
const char* DescribeGameType(GameType gameType) {
switch (gameType) {
case GameType::tes4:
return "The Elder Scrolls IV: Oblivion";
case GameType::tes5:
return "The Elder Scrolls V: Skyrim";
case GameType::fo3:
return "Fallout 3";
case GameType::fonv:
return "Fallout: New Vegas";
case GameType::fo4:
return "Fallout 4";
case GameType::tes5se:
return "The Elder Scrolls V: Skyrim Special Edition";
case GameType::fo4vr:
return "Fallout 4 VR";
case GameType::tes5vr:
return "The Elder Scrolls V: Skyrim VR";
case GameType::tes3:
return "The Elder Scrolls III: Morrowind";
default:
return "Unknown";
}
}
std::filesystem::path ResolvePath(const std::filesystem::path& path) {
// is_symlink can throw on MSVC with the message
// "symlink_status: The parameter is incorrect."
@@ -79,8 +104,9 @@ LOOT_API std::unique_ptr<GameInterface> CreateGameHandle(
auto logger = getLogger();
if (logger) {
logger->info(
"Attempting to create a game handle with game path \"{}\" "
"and local path \"{}\"",
"Attempting to create a game handle for game type \"{}\" with game "
"path \"{}\" and game local path \"{}\"",
DescribeGameType(game),
gamePath.u8string(),
gameLocalPath.u8string());
}
+1 -8
View File
@@ -62,14 +62,7 @@ Game::Game(const GameType gameType,
loadOrderHandler_(type_, gamePath_, localDataPath),
conditionEvaluator_(
std::make_shared<ConditionEvaluator>(Type(), DataPath())),
database_(ApiDatabase(conditionEvaluator_)) {
auto logger = getLogger();
if (logger) {
logger->info("Initialising load order data for game of type {} at: {}",
(int)type_,
gamePath_.u8string());
}
}
database_(ApiDatabase(conditionEvaluator_)) {}
GameType Game::Type() const { return type_; }
+6 -6
View File
@@ -73,8 +73,8 @@ TEST(SetLoggingCallback, shouldAcceptAMemberFunction) {
FAIL();
} catch (...) {
EXPECT_EQ(
"Attempting to create a game handle with game path \"dummy\" "
"and local path \"\"",
"Attempting to create a game handle for game type \"The Elder Scrolls "
"IV: Oblivion\" with game path \"dummy\" and game local path \"\"",
testLogger.loggedMessages);
SetLoggingCallback([](LogLevel, const char *) {});
@@ -112,8 +112,8 @@ TEST(SetLoggingCallback, shouldAcceptALambdaFunction) {
FAIL();
} catch (...) {
EXPECT_EQ(
"Attempting to create a game handle with game path \"dummy\" "
"and local path \"\"",
"Attempting to create a game handle for game type \"The Elder Scrolls "
"IV: Oblivion\" with game path \"dummy\" and game local path \"\"",
loggedMessages);
SetLoggingCallback([](LogLevel, const char *) {});
@@ -134,8 +134,8 @@ TEST(SetLoggingCallback,
FAIL();
} catch (...) {
EXPECT_EQ(
"Attempting to create a game handle with game path \"dummy\" "
"and local path \"\"",
"Attempting to create a game handle for game type \"The Elder Scrolls "
"IV: Oblivion\" with game path \"dummy\" and game local path \"\"",
loggedMessages);
SetLoggingCallback([](LogLevel, const char *) {});