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)
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}")
if (UNIX)

View File

@ -209,10 +209,12 @@ void RegisterThread(const std::string& str);
#define beammp_trace(x)
#endif // defined(DEBUG)
#define beammp_errorf(_format, _args) beammp_error(fmt::format(_format, _args))
#define beammp_infof(_format, _args) beammp_info(fmt::format(_format, _args))
#define beammp_warnf(_format, _args) beammp_warn(fmt::format(_format, _args))
#define beammp_tracef(_format, _args) beammp_trace(fmt::format(_format, _args))
#define beammp_errorf(...) beammp_error(fmt::format(__VA_ARGS__))
#define beammp_infof(...) beammp_info(fmt::format(__VA_ARGS__))
#define beammp_warnf(...) beammp_warn(fmt::format(__VA_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);

View File

@ -49,7 +49,7 @@ private:
{ "list", [this](const auto& a, const auto& b) { Command_List(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); } },
{ "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;

View File

@ -12,7 +12,7 @@ void ArgsParser::Parse(const std::vector<std::string_view>& ArgList) {
ConsumeLongFlag(std::string(Arg));
}
} 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;
for (const auto& RegisteredArg : mRegisteredArguments) {
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;
continue;
} 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;
}
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)) {
return;
}
@ -203,7 +203,7 @@ std::string TConsole::ConcatArgs(const std::vector<std::string>& args, char spac
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))) {
return;
}
@ -290,7 +290,7 @@ std::tuple<std::string, std::vector<std::string>> TConsole::ParseCommand(const s
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)) {
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.");
}
};
mCommandline.on_autocomplete = [this](Commandline& c, std::string stub, int) {
mCommandline.on_autocomplete = [this](Commandline&, std::string stub, int) {
std::vector<std::string> suggestions;
try {
auto cmd = TrimString(stub);
//beammp_error("yes 1");
//beammp_error(stub);
// beammp_error("yes 1");
// beammp_error(stub);
if (mIsLuaConsole) { // if lua
if (!mLuaEngine) {
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);
if (n == 0) {
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);
if (n == 0) {
suggestions.push_back(cmd_name);
//beammp_warn(cmd_name);
// beammp_warn(cmd_name);
}
}
}

View File

@ -116,7 +116,7 @@ void TNetwork::TCPServerMain() {
SOCKET Listener = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (Listener == BEAMMP_INVALID_SOCKET) {
beammp_error("Failed to create socket: " + GetPlatformAgnosticErrorString()
+ ". This is a fatal error, as a socket is needed for the server to operate. Shutting down.");
+ ". This is a fatal error, as a socket is needed for the server to operate. Shutting down.");
Application::GracefullyShutdown();
}
#if defined(BEAMMP_WINDOWS)

View File

@ -113,7 +113,7 @@ int BeamMPServerMain(MainArguments Arguments) {
try {
fs::current_path(fs::path(MaybeWorkingDirectory.value()));
} 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());
}
}
}