use fmt properly in beammp_*f logging functions

This commit is contained in:
Lion Kortlepel 2022-03-24 14:45:53 +01:00
parent 9e0d02c6db
commit 7a814ed35e
No known key found for this signature in database
GPG Key ID: 4322FF2B4C71259B
7 changed files with 20 additions and 18 deletions

View File

@ -138,7 +138,7 @@ else()
find_package(OpenSSL REQUIRED) find_package(OpenSSL REQUIRED)
endif() endif()
target_link_libraries(BeamMP-Server sol2::sol2 ${LUA_LIBRARIES}) target_link_libraries(BeamMP-Server sol2::sol2 ${LUA_LIBRARIES} fmt::fmt)
message(STATUS "CURL IS ${CURL_LIBRARIES}") message(STATUS "CURL IS ${CURL_LIBRARIES}")
if (UNIX) if (UNIX)

View File

@ -209,10 +209,12 @@ void RegisterThread(const std::string& str);
#define beammp_trace(x) #define beammp_trace(x)
#endif // defined(DEBUG) #endif // defined(DEBUG)
#define beammp_errorf(_format, _args) beammp_error(fmt::format(_format, _args)) #define beammp_errorf(...) beammp_error(fmt::format(__VA_ARGS__))
#define beammp_infof(_format, _args) beammp_info(fmt::format(_format, _args)) #define beammp_infof(...) beammp_info(fmt::format(__VA_ARGS__))
#define beammp_warnf(_format, _args) beammp_warn(fmt::format(_format, _args)) #define beammp_warnf(...) beammp_warn(fmt::format(__VA_ARGS__))
#define beammp_tracef(_format, _args) beammp_trace(fmt::format(_format, _args)) #define beammp_tracef(...) beammp_trace(fmt::format(__VA_ARGS__))
#define beammp_lua_errorf(...) beammp_lua_error(fmt::format(__VA_ARGS__))
#define beammp_lua_warnf(...) beammp_lua_warn(fmt::format(__VA_ARGS__))
void LogChatMessage(const std::string& name, int id, const std::string& msg); void LogChatMessage(const std::string& name, int id, const std::string& msg);

View File

@ -49,7 +49,7 @@ private:
{ "list", [this](const auto& a, const auto& b) { Command_List(a, b); } }, { "list", [this](const auto& a, const auto& b) { Command_List(a, b); } },
{ "status", [this](const auto& a, const auto& b) { Command_Status(a, b); } }, { "status", [this](const auto& a, const auto& b) { Command_Status(a, b); } },
{ "settings", [this](const auto& a, const auto& b) { Command_Settings(a, b); } }, { "settings", [this](const auto& a, const auto& b) { Command_Settings(a, b); } },
{ "say", [this](const auto& a, const auto& b) { Command_Say(""); } }, // shouldn't actually be called { "say", [this](const auto&, const auto&) { Command_Say(""); } }, // shouldn't actually be called
}; };
Commandline mCommandline; Commandline mCommandline;

View File

@ -12,7 +12,7 @@ void ArgsParser::Parse(const std::vector<std::string_view>& ArgList) {
ConsumeLongFlag(std::string(Arg)); ConsumeLongFlag(std::string(Arg));
} }
} else { } else {
beammp_error("Error parsing commandline arguments: Supplied argument '" + std::string(Arg) + "' is not a valid argument and was ignored."); beammp_errorf("Error parsing commandline arguments: Supplied argument '{}' is not a valid argument and was ignored.", Arg);
} }
} }
} }
@ -21,7 +21,7 @@ bool ArgsParser::Verify() {
bool Ok = true; bool Ok = true;
for (const auto& RegisteredArg : mRegisteredArguments) { for (const auto& RegisteredArg : mRegisteredArguments) {
if (RegisteredArg.Flags & Flags::REQUIRED && !FoundArgument(RegisteredArg.Names)) { if (RegisteredArg.Flags & Flags::REQUIRED && !FoundArgument(RegisteredArg.Names)) {
beammp_error("Error in commandline arguments: Argument '" + std::string(RegisteredArg.Names.at(0)) + "' is required but wasn't found."); beammp_errorf("Error in commandline arguments: Argument '{}' is required but wasn't found.", RegisteredArg.Names.at(0));
Ok = false; Ok = false;
continue; continue;
} else if (FoundArgument(RegisteredArg.Names)) { } else if (FoundArgument(RegisteredArg.Names)) {

View File

@ -160,7 +160,7 @@ bool TConsole::EnsureArgsCount(const std::vector<std::string>& args, size_t min,
return true; return true;
} }
void TConsole::Command_Lua(const std::string& cmd, const std::vector<std::string>& args) { void TConsole::Command_Lua(const std::string&, const std::vector<std::string>& args) {
if (!EnsureArgsCount(args, 0, 1)) { if (!EnsureArgsCount(args, 0, 1)) {
return; return;
} }
@ -203,7 +203,7 @@ std::string TConsole::ConcatArgs(const std::vector<std::string>& args, char spac
return Result; return Result;
} }
void TConsole::Command_Kick(const std::string& cmd, const std::vector<std::string>& args) { void TConsole::Command_Kick(const std::string&, const std::vector<std::string>& args) {
if (!EnsureArgsCount(args, 1, size_t(-1))) { if (!EnsureArgsCount(args, 1, size_t(-1))) {
return; return;
} }
@ -290,7 +290,7 @@ std::tuple<std::string, std::vector<std::string>> TConsole::ParseCommand(const s
return { Command, Args }; return { Command, Args };
} }
void TConsole::Command_Settings(const std::string& cmd, const std::vector<std::string>& args) { void TConsole::Command_Settings(const std::string&, const std::vector<std::string>& args) {
if (!EnsureArgsCount(args, 0)) { if (!EnsureArgsCount(args, 0)) {
return; return;
} }
@ -573,12 +573,12 @@ TConsole::TConsole() {
beammp_error("Console died with: " + std::string(e.what()) + ". This could be a fatal error and could cause the server to terminate."); beammp_error("Console died with: " + std::string(e.what()) + ". This could be a fatal error and could cause the server to terminate.");
} }
}; };
mCommandline.on_autocomplete = [this](Commandline& c, std::string stub, int) { mCommandline.on_autocomplete = [this](Commandline&, std::string stub, int) {
std::vector<std::string> suggestions; std::vector<std::string> suggestions;
try { try {
auto cmd = TrimString(stub); auto cmd = TrimString(stub);
//beammp_error("yes 1"); // beammp_error("yes 1");
//beammp_error(stub); // beammp_error(stub);
if (mIsLuaConsole) { // if lua if (mIsLuaConsole) { // if lua
if (!mLuaEngine) { if (!mLuaEngine) {
beammp_info("Lua not started yet, please try again in a second"); beammp_info("Lua not started yet, please try again in a second");
@ -596,7 +596,7 @@ TConsole::TConsole() {
std::string::size_type n = key.find(stub); std::string::size_type n = key.find(stub);
if (n == 0) { if (n == 0) {
suggestions.push_back(prefix + key); suggestions.push_back(prefix + key);
//beammp_warn(cmd_name); // beammp_warn(cmd_name);
} }
} }
} }
@ -605,7 +605,7 @@ TConsole::TConsole() {
std::string::size_type n = cmd_name.find(stub); std::string::size_type n = cmd_name.find(stub);
if (n == 0) { if (n == 0) {
suggestions.push_back(cmd_name); suggestions.push_back(cmd_name);
//beammp_warn(cmd_name); // beammp_warn(cmd_name);
} }
} }
} }

View File

@ -113,7 +113,7 @@ int BeamMPServerMain(MainArguments Arguments) {
try { try {
fs::current_path(fs::path(MaybeWorkingDirectory.value())); fs::current_path(fs::path(MaybeWorkingDirectory.value()));
} catch (const std::exception& e) { } catch (const std::exception& e) {
beammp_error("Could not set working directory to '" + MaybeWorkingDirectory.value() + "': " + e.what()); beammp_errorf("Could not set working directory to '{}': {}", MaybeWorkingDirectory.value(), e.what());
} }
} }
} }