Small updates and moved log location to Log folder

Fixed logger error
This commit is contained in:
Pax1601 2023-12-20 13:58:44 +01:00
parent 2e194d557a
commit 22ad5d5972
11 changed files with 49 additions and 20 deletions

View File

@ -9,7 +9,7 @@
href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@300;600;700;800&display=swap" />
<meta charset="UTF-8">
<title>DCS Olympus Manager v{{OLYMPUS_VERSION_NUMBER}}</title>
<title>DCS Olympus Manager {{OLYMPUS_VERSION_NUMBER}}</title>
</head>
<body>
@ -24,7 +24,7 @@
<img class="main-icon" src="../img/OlympusLogoFinal_4k.png" \>
<div>
<div> DCS Olympus Manager</div>
<div class="accent-green">v{{OLYMPUS_VERSION_NUMBER}}</div>
<div class="accent-green">{{OLYMPUS_VERSION_NUMBER}}</div>
</div>
<div>
These are the DCS instances that the Olympus Manager has automatically detected in your system. <br>

View File

@ -108,13 +108,13 @@ function delay(ms) {
async function installOlympus(folder) {
console.log(`Installing Olympus in ${folder}`);
fs.cpSync(path.join("..", "mod"), path.join(folder, "Mods", "Services", "Olympus"), {recursive: true});
fs.cpSync(path.join("..", "scripts", "OlympusHook.lua"), path.join(folder, "Scripts", "OlympusHook.lua"));
fs.cpSync(path.join("..", "scripts", "OlympusHook.lua"), path.join(folder, "Scripts", "Hook", "OlympusHook.lua"));
fs.cpSync(path.join("..", "olympus.json"), path.join(folder, "Config", "olympus.json"));
if (createDesktopShortcut({
windows: {
filePath: path.resolve(__dirname, '..', '..', 'client', 'client.vbs'),
outputPath: folder,
name: "DCS Olympus client",
name: "DCS Olympus Client",
arguments: `"${path.join(folder, "Config", "olympus.json")}"`,
icon: path.resolve(__dirname, '..', '..', 'img', 'olympus.ico'),
workingDirectory: path.resolve(__dirname, '..', '..', 'client')
@ -124,7 +124,7 @@ async function installOlympus(folder) {
windows: {
filePath: path.resolve(__dirname, '..', '..', 'client', 'server.vbs'),
outputPath: folder,
name: "DCS Olympus server",
name: "DCS Olympus Server",
arguments: `"${path.join(folder, "Config", "olympus.json")}"`,
icon: path.resolve(__dirname, '..', '..', 'img', 'olympus_server.ico'),
workingDirectory: path.resolve(__dirname, '..', '..', 'client')
@ -207,7 +207,7 @@ class InstanceDiv {
if (createDesktopShortcut({
windows: {
filePath: path.resolve(__dirname, '..', '..', 'client', 'client.vbs'),
name: "DCS Olympus client",
name: "DCS Olympus Client",
arguments: `"${path.join(this.folder, "Config", "olympus.json")}"`,
icon: path.resolve(__dirname, '..', '..', 'img', 'olympus.ico'),
workingDirectory: path.resolve(__dirname, '..', '..', 'client')
@ -215,7 +215,7 @@ class InstanceDiv {
}) && createDesktopShortcut({
windows: {
filePath: path.resolve(__dirname, '..', '..', 'client', 'server.vbs'),
name: "DCS Olympus server",
name: "DCS Olympus Server",
arguments: `"${path.join(this.folder, "Config", "olympus.json")}"`,
icon: path.resolve(__dirname, '..', '..', 'img', 'olympus_server.ico'),
workingDirectory: path.resolve(__dirname, '..', '..', 'client')

View File

@ -15,7 +15,7 @@ function createWindow() {
preload: path.join(__dirname, "javascripts", 'preload.js'),
nodeIntegration: true, // like here
},
icon: "./../img/olympus.ico"
icon: "./../img/olympus_configurator.ico"
});
window.loadFile('index.html').then(() => { window.show(); });

View File

@ -70,7 +70,7 @@ body {
}
#header>div:first-child>div:last-child {
color: green;
width: 100px;
}
#header>div:last-child {

View File

@ -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);
}

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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()

View File

@ -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";

View File

@ -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"