This commit is contained in:
2026-03-29 13:10:21 +02:00
parent f7c8cf56e3
commit 9f2fdd8af9
4 changed files with 18 additions and 14 deletions
+8 -6
View File
@@ -1,4 +1,5 @@
#include "git_version.h" #include "git_version.h"
#include "magic_enum/magic_enum.hpp"
#include "mainwindow.hpp" #include "mainwindow.hpp"
#include "spdlog/async.h" #include "spdlog/async.h"
#include "spdlog/sinks/stdout_color_sinks.h" #include "spdlog/sinks/stdout_color_sinks.h"
@@ -8,7 +9,6 @@
#include <QCommandLineParser> #include <QCommandLineParser>
#include <QProcess> #include <QProcess>
#include <QUrl> #include <QUrl>
#include "magic_enum/magic_enum.hpp"
#ifdef EMSCRIPTEN #ifdef EMSCRIPTEN
#include <emscripten.h> #include <emscripten.h>
@@ -56,16 +56,18 @@ int main(int argc, char *argv[])
QCoreApplication::translate("main", "default"), QLatin1String("")); QCoreApplication::translate("main", "default"), QLatin1String(""));
parser.addOption(default_sim_option); parser.addOption(default_sim_option);
QCommandLineOption log_option(QStringList() << "l" QCommandLineOption log_option(
<< "log", QStringList() << "l"
QCoreApplication::translate("main", "Log level for the unisim server [default: trace]."), << "log",
QCoreApplication::translate("main", "log"), QLatin1String("trace")); QCoreApplication::translate("main", "Log level for the unisim server [default: trace]."),
QCoreApplication::translate("main", "log"), QLatin1String("trace"));
parser.addOption(log_option); parser.addOption(log_option);
parser.process(a); parser.process(a);
// Initialize the logger // Initialize the logger
init_logger(); init_logger();
spdlog::set_level(magic_enum::enum_cast<spdlog::level::level_enum>(parser.value(log_option).toStdString()).value_or(spdlog::level::off)); spdlog::set_level(magic_enum::enum_cast<spdlog::level::level_enum>(parser.value(log_option).toStdString())
.value_or(spdlog::level::off));
QUrl url; QUrl url;
url.setScheme("ws"); url.setScheme("ws");
+1 -1
View File
@@ -20,7 +20,7 @@ MainWindow::MainWindow(QUrl ws_url, QString sim, QWidget *parent)
[](const char *filename_in, int line_in, const char *funcname_in, int level, QString msg) { [](const char *filename_in, int line_in, const char *funcname_in, int level, QString msg) {
if (spdlog::default_logger_raw()->should_log((spdlog::level::level_enum)level)) if (spdlog::default_logger_raw()->should_log((spdlog::level::level_enum)level))
spdlog::default_logger_raw()->log(spdlog::source_loc{filename_in, line_in, funcname_in}, spdlog::default_logger_raw()->log(spdlog::source_loc{filename_in, line_in, funcname_in},
(spdlog::level::level_enum)level, msg.toStdString()); (spdlog::level::level_enum)level, msg.toStdString());
}); });
QDirIterator it(QCoreApplication::applicationDirPath(), QStringList() << "*libui_*.so" << "*libui_*.dll", QDirIterator it(QCoreApplication::applicationDirPath(), QStringList() << "*libui_*.so" << "*libui_*.dll",
+8 -6
View File
@@ -6,8 +6,8 @@
#include "spdlog/sinks/stdout_color_sinks.h" #include "spdlog/sinks/stdout_color_sinks.h"
#include "spdlog/spdlog.h" #include "spdlog/spdlog.h"
#include "magic_enum/magic_enum.hpp"
#include "git_version.h" #include "git_version.h"
#include "magic_enum/magic_enum.hpp"
#include "simulators.hpp" #include "simulators.hpp"
void init_logger() void init_logger()
@@ -38,10 +38,11 @@ int main(int argc, char *argv[])
<< "port", << "port",
QCoreApplication::translate("main", "Port for the unisim server [default: 9002]."), QCoreApplication::translate("main", "Port for the unisim server [default: 9002]."),
QCoreApplication::translate("main", "port"), QLatin1String("9002")); QCoreApplication::translate("main", "port"), QLatin1String("9002"));
QCommandLineOption log_option(QStringList() << "l" QCommandLineOption log_option(
<< "log", QStringList() << "l"
QCoreApplication::translate("main", "Log level for the unisim server [default: trace]."), << "log",
QCoreApplication::translate("main", "log"), QLatin1String("trace")); QCoreApplication::translate("main", "Log level for the unisim server [default: trace]."),
QCoreApplication::translate("main", "log"), QLatin1String("trace"));
QCommandLineOption can_port0_option(QStringList() << "c" << "c0", QCommandLineOption can_port0_option(QStringList() << "c" << "c0",
QCoreApplication::translate("main", "CAN device 0."), QCoreApplication::translate("main", "CAN device 0."),
QCoreApplication::translate("main", "can device 0.")); QCoreApplication::translate("main", "can device 0."));
@@ -76,7 +77,8 @@ int main(int argc, char *argv[])
// Initialize the logger // Initialize the logger
init_logger(); init_logger();
spdlog::set_level(magic_enum::enum_cast<spdlog::level::level_enum>(parser.value(log_option).toStdString()).value_or(spdlog::level::off)); spdlog::set_level(magic_enum::enum_cast<spdlog::level::level_enum>(parser.value(log_option).toStdString())
.value_or(spdlog::level::off));
// The server starts in this thread // The server starts in this thread
SPDLOG_INFO("Starting server"); SPDLOG_INFO("Starting server");
+1 -1
View File
@@ -162,7 +162,7 @@ void Simulators::switch_simulator(std::string name)
[](const char *filename_in, int line_in, const char *funcname_in, int level, QString msg) { [](const char *filename_in, int line_in, const char *funcname_in, int level, QString msg) {
if (spdlog::default_logger_raw()->should_log((spdlog::level::level_enum)level)) if (spdlog::default_logger_raw()->should_log((spdlog::level::level_enum)level))
spdlog::default_logger_raw()->log(spdlog::source_loc{filename_in, line_in, funcname_in}, spdlog::default_logger_raw()->log(spdlog::source_loc{filename_in, line_in, funcname_in},
(spdlog::level::level_enum)level, msg.toStdString()); (spdlog::level::level_enum)level, msg.toStdString());
}); });
this->start(); this->start();
} }