Logging library with setup

This commit is contained in:
Anonymous-275
2021-12-27 00:36:12 +02:00
parent 94a7372e2c
commit f19d92eebc
7 changed files with 7022 additions and 5 deletions

24
src/Launcher.cpp Normal file
View File

@@ -0,0 +1,24 @@
///
/// Created by Anonymous275 on 12/26/21
/// Copyright (c) 2021-present Anonymous275 read the LICENSE file for more info.
///
#include "Launcher.h"
#include <Logger.h>
Launcher::Launcher(int argc, char **argv) : DirPath(argv[0]) {
DirPath = DirPath.substr(0, DirPath.find_last_of("\\/") + 1);
Log::Init(argc, argv);
WindowsInit();
}
#ifdef WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
void Launcher::WindowsInit() {
system("cls");
SetConsoleTitleA(("BeamMP Launcher v" + FullVersion).c_str());
}
#else //WIN32
void Launcher::WindowsInit() {}
#endif //WIN32

23
src/Logger.cpp Normal file
View File

@@ -0,0 +1,23 @@
///
/// Created by Anonymous275 on 12/26/21
/// Copyright (c) 2021-present Anonymous275 read the LICENSE file for more info.
///
#include "Logger.h"
INITIALIZE_EASYLOGGINGPP
void Log::Init(int argc, char **argv) {
el::Helpers::setArgs(argc, argv);
el::Configurations Conf;
Conf.setToDefault();
std::string DFormat("%datetime{[%d/%M/%y %H:%m:%s]} %fbase:%line [%level] %msg");
Conf.setGlobally(el::ConfigurationType::Format, "%datetime{[%d/%M/%y %H:%m:%s]} [%level] %msg");
Conf.set(el::Level::Debug,el::ConfigurationType::Format, DFormat);
Conf.set(el::Level::Trace,el::ConfigurationType::Format, DFormat);
Conf.set(el::Level::Fatal,el::ConfigurationType::Format, DFormat);
Conf.setGlobally(el::ConfigurationType::Filename, "Launcher.log");
Conf.setGlobally(el::ConfigurationType::MaxLogFileSize, "2097152");
el::Loggers::reconfigureAllLoggers(Conf);
el::Loggers::addFlag(el::LoggingFlag::DisableApplicationAbortOnFatalLog);
el::Loggers::addFlag(el::LoggingFlag::HierarchicalLogging);
el::Loggers::setLoggingLevel(el::Level::Global);
}

View File

@@ -3,7 +3,9 @@
/// Copyright (c) 2021-present Anonymous275 read the LICENSE file for more info.
///
int main() {
#include "Launcher.h"
int main(int argc, char* argv[]) {
Launcher launcher(argc, argv);
return 0;
}