diff --git a/src/Logger/Logger.cpp b/src/Logger/Logger.cpp index 7ae0f9d..3758e44 100644 --- a/src/Logger/Logger.cpp +++ b/src/Logger/Logger.cpp @@ -16,7 +16,10 @@ #include +#include +#include #include +#include #include "Logger.h" @@ -33,12 +36,13 @@ Logger::instance() { void Logger::initialise() { + auto exe_path = Utility::Path::split(*Utility::Path::executableLocation()).first(); + _logFile.open(Utility::Path::join(exe_path, "SaveToolLog.txt").cbegin(), std::ios::trunc); #ifndef SAVETOOL_DEBUG_BUILD - _logFile.open("SaveToolLog.txt", std::ios::trunc); _logFile << "In case you encounter a bug:\n" << "1. Do not run the Save Tool again, as this log will be cleared.\n" << "2. Go to either the official Sekai Project Discord guild, or the community M.A.S.S. Builder one.\n" << - "3. Mention me (William JCM#2301) to get my attention, with a description of the bug.\n" + "3. Mention me (@williamjcm) to get my attention, with a description of the bug.\n" " Please include as many details as possible, I don't want to play \"20 questions\", and neither do you.\n" << "4. Send me this file _when I ask for it_, preferably in DMs.\n" << std::endl; @@ -59,31 +63,19 @@ Logger::unindent() { void Logger::log(EntryType type, StringView location, StringView message) { - Debug d{ - #ifndef SAVETOOL_DEBUG_BUILD - &_logFile - #else - &std::cout - #endif - }; + Debug d{&_logFile}; - #ifdef SAVETOOL_DEBUG_BUILD - #define COLOURED_TEXT(colour, text) Debug::color(Debug::Color::colour) << (text) << Debug::resetColor - #else - #define COLOURED_TEXT(colour, text) (text) - #endif switch(type) { case EntryType::Info: - d << COLOURED_TEXT(Default, "[ INFO]"_s); + d << "[ INFO]"_s; break; case EntryType::Warning: - d << COLOURED_TEXT(Yellow, "[WARNING]"_s); + d << "[WARNING]"_s; break; case EntryType::Error: - d << COLOURED_TEXT(Red, "[ ERROR]"_s); + d << "[ ERROR]"_s; break; } - #undef COLOURED_TEXT d << "["_s << Debug::nospace << location << Debug::nospace << "]"; diff --git a/src/Logger/Logger.h b/src/Logger/Logger.h index 9bb793b..ef35418 100644 --- a/src/Logger/Logger.h +++ b/src/Logger/Logger.h @@ -18,10 +18,8 @@ #include -#include -#ifndef SAVETOOL_DEBUG_BUILD #include -#endif +#include #include #include @@ -60,9 +58,7 @@ class Logger { private: Logger() = default; - #ifndef SAVETOOL_DEBUG_BUILD std::ofstream _logFile; - #endif std::uint32_t _indentLevel = 0;