diff --git a/Common/inc/Logger.h b/Common/inc/Logger.h index e53daeb..d0fd675 100644 --- a/Common/inc/Logger.h +++ b/Common/inc/Logger.h @@ -1,9 +1,11 @@ namespace LX { + // Static class used for logging information // class COMMON_API Log { public: // This class should never be constructed // + // It acts like a fancy namespace // Log() = delete; enum class Format @@ -15,15 +17,11 @@ namespace LX template static void out(Args... args) { - if constexpr (format == Format::AUTO) - { - ((*s_LogFile << ... << args) << "\n"); - } + // Prints out the args ending with a new line unless specified // + if constexpr (format == Format::AUTO) { ((*s_LogFile << ... << args) << "\n"); } - else - { - (*s_LogFile << ... << args); - } + // Else prints out the args as provided // + else { (*s_LogFile << ... << args); } } template @@ -36,13 +34,11 @@ namespace LX *s_LogFile << '\n' << BREAK << '\n'; } - private: // Initalises the log (Called by DllMain) // static void Init(); - // Closes the log (Called by DllMain) // - static void Close(); - + private: + // Keeps the pointer hidden to stop accidental changes // static std::ofstream* s_LogFile; }; } diff --git a/Common/src/Logger.cpp b/Common/src/Logger.cpp index d751907..8dc18c8 100644 --- a/Common/src/Logger.cpp +++ b/Common/src/Logger.cpp @@ -15,12 +15,4 @@ namespace LX actualLog.open("log"); s_LogFile = &actualLog; } - - void Log::Close() - { - // Flushes and closes the log // - // Yes I know closing automatically flushes but this function looked empty // - s_LogFile->flush(); - s_LogFile->close(); - } } diff --git a/IR-Generator/src/Generator.cpp b/IR-Generator/src/Generator.cpp index c2a11a9..92002b7 100644 --- a/IR-Generator/src/Generator.cpp +++ b/IR-Generator/src/Generator.cpp @@ -3,6 +3,8 @@ #include #include +#include <../Lexer/inc/LexerErrors.h> // <- TEMP (I hope) + namespace LX { // Different errors thrown by main // @@ -35,6 +37,9 @@ namespace LX extern "C" int __declspec(dllexport) GenIR(const char* a_inpPath, const char* a_outPath) { + // Initalises the log // + LX::Log::Init(); + // Creates the file paths outside of the try-catch so they can be used in errors // std::filesystem::path inpPath; std::filesystem::path outPath;