mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-11 05:51:51 +00:00
add '--log' command line parameter
This commit is contained in:
parent
8b520a3787
commit
7c9fff19e4
3 changed files with 14 additions and 1 deletions
|
|
@ -12,6 +12,7 @@ struct CoreParameters {
|
||||||
std::filesystem::path userFolder = ".";
|
std::filesystem::path userFolder = ".";
|
||||||
std::filesystem::path scriptFile;
|
std::filesystem::path scriptFile;
|
||||||
std::filesystem::path projectFolder;
|
std::filesystem::path projectFolder;
|
||||||
|
std::filesystem::path logFile;
|
||||||
std::string debugServerString;
|
std::string debugServerString;
|
||||||
int tps = 20;
|
int tps = 20;
|
||||||
int subProcessDepth = 0;
|
int subProcessDepth = 0;
|
||||||
|
|
|
||||||
10
src/main.cpp
10
src/main.cpp
|
|
@ -7,6 +7,7 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
|
using namespace std::literals;
|
||||||
static debug::Logger logger("main");
|
static debug::Logger logger("main");
|
||||||
|
|
||||||
static void sigterm_handler(int signum) {
|
static void sigterm_handler(int signum) {
|
||||||
|
|
@ -36,7 +37,14 @@ int main(int argc, char** argv) {
|
||||||
#ifdef NDEBUG
|
#ifdef NDEBUG
|
||||||
std::signal(SIGINT, sigterm_handler);
|
std::signal(SIGINT, sigterm_handler);
|
||||||
#endif
|
#endif
|
||||||
debug::Logger::init(coreParameters.userFolder.string() + "/latest.log");
|
std::filesystem::path logFile = coreParameters.logFile;
|
||||||
|
if (logFile.empty()) {
|
||||||
|
logFile = coreParameters.userFolder.string() + "/latest"s +
|
||||||
|
(coreParameters.subProcessDepth > 0
|
||||||
|
? ".sub" + std::to_string(coreParameters.subProcessDepth)
|
||||||
|
: "") + ".log"s;
|
||||||
|
}
|
||||||
|
debug::Logger::init(logFile);
|
||||||
platform::configure_encoding();
|
platform::configure_encoding();
|
||||||
|
|
||||||
auto& engine = Engine::getInstance();
|
auto& engine = Engine::getInstance();
|
||||||
|
|
|
||||||
|
|
@ -82,6 +82,10 @@ static bool perform_keyword(
|
||||||
params.subProcessDepth = reader.nextInt();
|
params.subProcessDepth = reader.nextInt();
|
||||||
return true;
|
return true;
|
||||||
}, "<depth>", "sub-process depth"),
|
}, "<depth>", "sub-process depth"),
|
||||||
|
ArgC("--log", [](auto& params, auto& reader) -> bool {
|
||||||
|
params.logFile = reader.next();
|
||||||
|
return true;
|
||||||
|
}, "<file>", "target log file"),
|
||||||
ArgC("--help", [](auto&, auto&) -> bool {
|
ArgC("--help", [](auto&, auto&) -> bool {
|
||||||
std::cout << "VoxelCore v" << ENGINE_VERSION_STRING << "\n\n";
|
std::cout << "VoxelCore v" << ENGINE_VERSION_STRING << "\n\n";
|
||||||
std::cout << "Command-line arguments:\n";
|
std::cout << "Command-line arguments:\n";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue