mirror of
https://github.com/BeamMP/BeamMP-Launcher.git
synced 2025-07-04 00:47:23 +00:00
Logging library with setup
This commit is contained in:
parent
94a7372e2c
commit
f19d92eebc
@ -1,5 +1,5 @@
|
|||||||
cmake_minimum_required(VERSION 3.10)
|
cmake_minimum_required(VERSION 3.0)
|
||||||
project(Launcher)
|
project(BeamMP-Launcher)
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
message(STATUS "MSVC -> forcing use of statically-linked runtime.")
|
message(STATUS "MSVC -> forcing use of statically-linked runtime.")
|
||||||
@ -13,9 +13,9 @@ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG")
|
|||||||
|
|
||||||
add_executable(${PROJECT_NAME}
|
add_executable(${PROJECT_NAME}
|
||||||
src/main.cpp
|
src/main.cpp
|
||||||
|
src/Launcher.cpp include/Launcher.h
|
||||||
|
src/Logger.cpp include/Logger.h
|
||||||
)
|
)
|
||||||
set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME "BeamMP-Launcher")
|
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
find_package(ZLIB REQUIRED)
|
find_package(ZLIB REQUIRED)
|
||||||
find_package(OpenSSL REQUIRED)
|
find_package(OpenSSL REQUIRED)
|
||||||
@ -25,6 +25,8 @@ if (WIN32)
|
|||||||
link_directories(${VcpkgRoot}/lib)
|
link_directories(${VcpkgRoot}/lib)
|
||||||
target_link_libraries(${PROJECT_NAME} PRIVATE ${VcpkgRoot}/lib/discord-rpc.lib
|
target_link_libraries(${PROJECT_NAME} PRIVATE ${VcpkgRoot}/lib/discord-rpc.lib
|
||||||
ZLIB::ZLIB OpenSSL::SSL OpenSSL::Crypto ws2_32)
|
ZLIB::ZLIB OpenSSL::SSL OpenSSL::Crypto ws2_32)
|
||||||
|
elseif (UNIX)
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s")
|
||||||
else(WIN32) #MINGW
|
else(WIN32) #MINGW
|
||||||
add_definitions("-D_WIN32_WINNT=0x0600")
|
add_definitions("-D_WIN32_WINNT=0x0600")
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Os -s --static")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Os -s --static")
|
||||||
|
22
include/Launcher.h
Normal file
22
include/Launcher.h
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
///
|
||||||
|
/// Created by Anonymous275 on 12/26/21
|
||||||
|
/// Copyright (c) 2021-present Anonymous275 read the LICENSE file for more info.
|
||||||
|
///
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
class Launcher {
|
||||||
|
public:
|
||||||
|
Launcher(int argc, char* argv[]);
|
||||||
|
const std::string& getWorkingDir(){return DirPath;}
|
||||||
|
const std::string& getVersion(){return Version;}
|
||||||
|
const std::string& getFullVersion(){return FullVersion;}
|
||||||
|
private:
|
||||||
|
void WindowsInit();
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string DirPath;
|
||||||
|
std::string Version{"3.0"};
|
||||||
|
std::string FullVersion{Version + ".0"};
|
||||||
|
};
|
12
include/Logger.h
Normal file
12
include/Logger.h
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
///
|
||||||
|
/// Created by Anonymous275 on 12/26/21
|
||||||
|
/// Copyright (c) 2021-present Anonymous275 read the LICENSE file for more info.
|
||||||
|
///
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "easylogging++.h"
|
||||||
|
|
||||||
|
class Log {
|
||||||
|
public:
|
||||||
|
static void Init(int argc, char* argv[]);
|
||||||
|
};
|
6932
include/easylogging++.h
Normal file
6932
include/easylogging++.h
Normal file
File diff suppressed because it is too large
Load Diff
24
src/Launcher.cpp
Normal file
24
src/Launcher.cpp
Normal 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
23
src/Logger.cpp
Normal 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);
|
||||||
|
}
|
@ -3,7 +3,9 @@
|
|||||||
/// Copyright (c) 2021-present Anonymous275 read the LICENSE file for more info.
|
/// 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;
|
return 0;
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user