mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2026-04-05 07:16:18 +00:00
Fully Polished the loggin system
This commit is contained in:
32
src/main.cpp
32
src/main.cpp
@@ -5,15 +5,16 @@
|
||||
#include "main.h"
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include "logger.h"
|
||||
|
||||
using namespace std; //nameSpace STD
|
||||
|
||||
void DebugData();
|
||||
void LogInit();
|
||||
void ParseConfig();
|
||||
void ServerMain(int Port, int MaxClients);
|
||||
|
||||
bool Debug = false;
|
||||
void addToLog(basic_string<char> Data);
|
||||
int Port = 30814;
|
||||
int MaxClients = 10;
|
||||
string MapName = "levels/gridmap/level.json";
|
||||
@@ -22,11 +23,11 @@ string ServerName = "BeamNG-MP FTW";
|
||||
//Entry
|
||||
int main() {
|
||||
ParseConfig();
|
||||
LogInit();
|
||||
if(Debug){ //checks if debug is on
|
||||
DebugData(); //Prints Debug Data
|
||||
}
|
||||
setLoggerLevel("ALL");
|
||||
|
||||
ServerMain(Port, MaxClients);
|
||||
}
|
||||
|
||||
@@ -47,3 +48,28 @@ void SetMainValues(bool D, int P,int MP,string Name,string serverName){
|
||||
MaxClients = MP;
|
||||
}
|
||||
|
||||
void LogInit(){
|
||||
ifstream InFileStream;
|
||||
InFileStream.open("Server.log");
|
||||
if(InFileStream.good()){
|
||||
remove("Server.log");
|
||||
}
|
||||
InFileStream.close();
|
||||
}
|
||||
|
||||
void addToLog(basic_string<char> Data){
|
||||
basic_string<char> LogData = "";
|
||||
ifstream InFileStream;
|
||||
InFileStream.open("Server.log");
|
||||
if(InFileStream.good()){
|
||||
string line;
|
||||
while (getline(InFileStream, line)) {
|
||||
LogData = LogData + line + "\n";
|
||||
}
|
||||
}
|
||||
ofstream LFS;
|
||||
LFS.open ("Server.log");
|
||||
LFS << LogData;
|
||||
LFS << Data.c_str();
|
||||
LFS.close();
|
||||
}
|
||||
Reference in New Issue
Block a user