mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
Small updates and moved log location to Log folder
Fixed logger error
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#include "logger.h"
|
||||
#include "luatools.h"
|
||||
#include "dcstools.h"
|
||||
#include "defines.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@@ -38,9 +39,9 @@ void registerLuaFunctions(lua_State* L)
|
||||
log("protectedCall registered successfully");
|
||||
}
|
||||
|
||||
executeLuaScript(L, instancePath + "..\\Scripts\\mist.lua");
|
||||
executeLuaScript(L, instancePath + "..\\Scripts\\OlympusCommand.lua");
|
||||
executeLuaScript(L, instancePath + "..\\Scripts\\unitPayloads.lua");
|
||||
executeLuaScript(L, instancePath + "..\\Scripts\\templates.lua");
|
||||
executeLuaScript(L, instancePath + "..\\Scripts\\mods.lua");
|
||||
executeLuaScript(L, instancePath + MIST_SCRIPT);
|
||||
executeLuaScript(L, instancePath + OLYMPUS_COMMAND_SCRIPT);
|
||||
executeLuaScript(L, instancePath + UNIT_PAYLOADS_SCRIPT);
|
||||
executeLuaScript(L, instancePath + TEMPLATES_SCRIPT);
|
||||
executeLuaScript(L, instancePath + MODS_SCRIPT);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
#include "framework.h"
|
||||
|
||||
void DllExport setLogDirectory(std::string m_dirPath);
|
||||
void DllExport log(const std::string& sMessage, bool addToJSON = false);
|
||||
void DllExport log(const std::wstring& sMessage, bool addToJSON = false);
|
||||
void DllExport getLogsJSON(json::value& json, unsigned long long time);
|
||||
|
||||
@@ -8,6 +8,7 @@ public:
|
||||
void log(const string& sMessage, bool addToJSON);
|
||||
void log(const wstring& sMessage, bool addToJSON);
|
||||
void toJSON(json::value& json, unsigned long long time);
|
||||
void setDirectory(string newDirPath);
|
||||
|
||||
static Logger* GetLogger();
|
||||
|
||||
@@ -20,6 +21,7 @@ private:
|
||||
static Logger* m_pThis;
|
||||
static ofstream m_Logfile;
|
||||
static std::map<unsigned long long, std::string> m_logs;
|
||||
static string m_dirPath;
|
||||
|
||||
mutex mutexLock;
|
||||
|
||||
|
||||
@@ -4,6 +4,11 @@
|
||||
|
||||
#define LOGGER Logger::GetLogger()
|
||||
|
||||
void setLogDirectory(string m_dirPath)
|
||||
{
|
||||
LOGGER->setDirectory(m_dirPath);
|
||||
}
|
||||
|
||||
void log(const string& message, bool addToJSON)
|
||||
{
|
||||
LOGGER->log(message, addToJSON);
|
||||
|
||||
@@ -8,25 +8,35 @@ const string Logger::m_sFileName = LOG_NAME;
|
||||
Logger* Logger::m_pThis = NULL;
|
||||
ofstream Logger::m_Logfile;
|
||||
std::map<unsigned long long, std::string> Logger::m_logs;
|
||||
std::string m_dirPath;
|
||||
|
||||
Logger::Logger()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Logger* Logger::GetLogger()
|
||||
{
|
||||
if (m_pThis == NULL) {
|
||||
m_pThis = new Logger();
|
||||
std::filesystem::path dirPath = std::filesystem::temp_directory_path();
|
||||
m_Logfile.open((dirPath.string() + m_sFileName).c_str(), ios::out);
|
||||
}
|
||||
return m_pThis;
|
||||
}
|
||||
|
||||
void Logger::setDirectory(string newDirPath)
|
||||
{
|
||||
m_dirPath = newDirPath;
|
||||
}
|
||||
|
||||
void Logger::Open()
|
||||
{
|
||||
std::filesystem::path dirPath = std::filesystem::temp_directory_path();
|
||||
m_Logfile.open((dirPath.string() + m_sFileName).c_str(), ios::out | ios::app);
|
||||
try {
|
||||
m_Logfile.open((m_dirPath + m_sFileName).c_str(), ios::out | ios::app);
|
||||
}
|
||||
catch (...) {
|
||||
std::filesystem::path m_dirPath = std::filesystem::temp_directory_path();
|
||||
m_Logfile.open((m_dirPath.string() + m_sFileName).c_str(), ios::out | ios::app);
|
||||
}
|
||||
}
|
||||
|
||||
void Logger::Close()
|
||||
|
||||
@@ -49,6 +49,9 @@ static int onSimulationStart(lua_State* L)
|
||||
{
|
||||
LogInfo(L, "Trying to load core.dll from " + modPath);
|
||||
SetDllDirectoryA(modPath.c_str());
|
||||
|
||||
setLogDirectory(modPath);
|
||||
|
||||
log("onSimulationStart callback called successfully");
|
||||
|
||||
string dllLocation = modPath + "\\core.dll";
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#define VERSION "v1.0.3.7bb90b4a8"
|
||||
#define LOG_NAME "Olympus_log.txt"
|
||||
#define REST_ADDRESS "http://localhost:30000"
|
||||
#define LOG_NAME "..\\..\\..\\..\\Logs\\Olympus_log.txt"
|
||||
|
||||
#define REST_ADDRESS "http://localhost:3001"
|
||||
#define REST_URI "olympus"
|
||||
#define UNITS_URI "units"
|
||||
#define WEAPONS_URI "weapons"
|
||||
@@ -19,3 +20,9 @@
|
||||
#define HELICOPTER_DATABASE_PATH "..\\databases\\units\\helicopterdatabase.json"
|
||||
#define GROUNDUNIT_DATABASE_PATH "..\\databases\\units\\groundunitdatabase.json"
|
||||
#define NAVYUNIT_DATABASE_PATH "..\\databases\\units\\navyunitdatabase.json"
|
||||
|
||||
#define MIST_SCRIPT "..\\Scripts\\mist.lua"
|
||||
#define OLYMPUS_COMMAND_SCRIPT "..\\Scripts\\OlympusCommand.lua"
|
||||
#define UNIT_PAYLOADS_SCRIPT "..\\Scripts\\unitPayloads.lua"
|
||||
#define TEMPLATES_SCRIPT "..\\Scripts\\templates.lua"
|
||||
#define MODS_SCRIPT "..\\Scripts\\mods.lua"
|
||||
|
||||
Reference in New Issue
Block a user