mirror of
https://github.com/PashaBibko/LX.git
synced 2026-04-03 17:39:02 +00:00
Fixed previous commit
This commit is contained in:
@@ -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;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user