Fixed previous commit

This commit is contained in:
Pasha Bibko
2025-05-06 17:43:26 +01:00
parent f3a559490c
commit 0c34e7174e
3 changed files with 13 additions and 20 deletions

View File

@@ -1,9 +1,11 @@
namespace LX namespace LX
{ {
// Static class used for logging information //
class COMMON_API Log class COMMON_API Log
{ {
public: public:
// This class should never be constructed // // This class should never be constructed //
// It acts like a fancy namespace //
Log() = delete; Log() = delete;
enum class Format enum class Format
@@ -15,15 +17,11 @@ namespace LX
template<Format format = Format::AUTO, typename... Args> template<Format format = Format::AUTO, typename... Args>
static void out(Args... args) static void out(Args... args)
{ {
if constexpr (format == Format::AUTO) // Prints out the args ending with a new line unless specified //
{ if constexpr (format == Format::AUTO) { ((*s_LogFile << ... << args) << "\n"); }
((*s_LogFile << ... << args) << "\n");
}
else // Else prints out the args as provided //
{ else { (*s_LogFile << ... << args); }
(*s_LogFile << ... << args);
}
} }
template<typename... Args> template<typename... Args>
@@ -36,13 +34,11 @@ namespace LX
*s_LogFile << '\n' << BREAK << '\n'; *s_LogFile << '\n' << BREAK << '\n';
} }
private:
// Initalises the log (Called by DllMain) // // Initalises the log (Called by DllMain) //
static void Init(); static void Init();
// Closes the log (Called by DllMain) // private:
static void Close(); // Keeps the pointer hidden to stop accidental changes //
static std::ofstream* s_LogFile; static std::ofstream* s_LogFile;
}; };
} }

View File

@@ -15,12 +15,4 @@ namespace LX
actualLog.open("log"); actualLog.open("log");
s_LogFile = &actualLog; 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();
}
} }

View File

@@ -3,6 +3,8 @@
#include <Parser.h> #include <Parser.h>
#include <Lexer.h> #include <Lexer.h>
#include <../Lexer/inc/LexerErrors.h> // <- TEMP (I hope)
namespace LX namespace LX
{ {
// Different errors thrown by main // // 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) 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 // // Creates the file paths outside of the try-catch so they can be used in errors //
std::filesystem::path inpPath; std::filesystem::path inpPath;
std::filesystem::path outPath; std::filesystem::path outPath;