aboutsummaryrefslogtreecommitdiffstats
path: root/src/coremods
diff options
context:
space:
mode:
authorGravatar Sadie Powell2025-01-23 16:35:32 +0000
committerGravatar Sadie Powell2025-01-23 16:35:32 +0000
commitb9fee8b43dc1903ecb08c81405fb83295fc64db9 (patch)
tree80d4bb49c9a2e0e36be0e348a3900d7bec2b7da5 /src/coremods
parentFix the list of supported exemptions. (diff)
Convert debug logging from string concatenation to format strings.
When running in normal mode this will prevent a bunch of expensive string concatenation.
Diffstat (limited to 'src/coremods')
-rw-r--r--src/coremods/core_channel/cmd_kick.cpp3
-rw-r--r--src/coremods/core_dns.cpp20
-rw-r--r--src/coremods/core_hostname_lookup.cpp4
3 files changed, 15 insertions, 12 deletions
diff --git a/src/coremods/core_channel/cmd_kick.cpp b/src/coremods/core_channel/cmd_kick.cpp
index 07a4fc12a..83916fa3b 100644
--- a/src/coremods/core_channel/cmd_kick.cpp
+++ b/src/coremods/core_channel/cmd_kick.cpp
@@ -85,7 +85,8 @@ CmdResult CommandKick::Handle(User* user, const Params& parameters)
// If the current membership id is not equal to the one in the message then the user rejoined
if (memb->id != Membership::IdFromString(parameters[2]))
{
- ServerInstance->Logs.Debug(MODNAME, "Dropped KICK due to membership id mismatch: " + ConvToStr(memb->id) + " != " + parameters[2]);
+ ServerInstance->Logs.Debug(MODNAME, "Dropped KICK due to membership id mismatch: {} != {}",
+ memb->id, parameters[2]);
return CmdResult::FAILURE;
}
}
diff --git a/src/coremods/core_dns.cpp b/src/coremods/core_dns.cpp
index 0caa67ce7..78d061ec8 100644
--- a/src/coremods/core_dns.cpp
+++ b/src/coremods/core_dns.cpp
@@ -55,7 +55,7 @@ private:
if (pos + name.length() + 2 > output_size)
throw Exception(creator, "Unable to pack name");
- ServerInstance->Logs.Debug(MODNAME, "Packing name " + name);
+ ServerInstance->Logs.Debug(MODNAME, "Packing name {}", name);
irc::sepstream sep(name, '.');
std::string token;
@@ -127,7 +127,7 @@ private:
if (name.empty())
throw Exception(creator, "Unable to unpack name - no name");
- ServerInstance->Logs.Debug(MODNAME, "Unpack name " + name);
+ ServerInstance->Logs.Debug(MODNAME, "Unpack name {}", name);
return name;
}
@@ -250,7 +250,7 @@ private:
}
if (!record.name.empty() && !record.rdata.empty())
- ServerInstance->Logs.Debug(MODNAME, record.name + " -> " + record.rdata);
+ ServerInstance->Logs.Debug(MODNAME, "{} -> {}", record.name, record.rdata);
return record;
}
@@ -296,7 +296,8 @@ public:
unsigned short arcount = (input[packet_pos] << 8) | input[packet_pos + 1];
packet_pos += 2;
- ServerInstance->Logs.Debug(MODNAME, "qdcount: " + ConvToStr(qdcount) + " ancount: " + ConvToStr(ancount) + " nscount: " + ConvToStr(nscount) + " arcount: " + ConvToStr(arcount));
+ ServerInstance->Logs.Debug(MODNAME, "qdcount: {} ancount: {} nscount: {} arcount: {}",
+ qdcount, ancount, nscount, arcount);
if (qdcount != 1)
throw Exception(creator, "Question count != 1 in incoming packet");
@@ -407,7 +408,7 @@ class MyManager final
*/
bool CheckCache(DNS::Request* req, const DNS::Question& question)
{
- ServerInstance->Logs.Critical(MODNAME, "cache: Checking cache for " + question.name);
+ ServerInstance->Logs.Critical(MODNAME, "cache: Checking cache for {}", question.name);
cache_map::iterator it = this->cache.find(question);
if (it == this->cache.end())
@@ -420,7 +421,7 @@ class MyManager final
return false;
}
- ServerInstance->Logs.Debug(MODNAME, "cache: Using cached result for " + question.name);
+ ServerInstance->Logs.Debug(MODNAME, "cache: Using cached result for {}", question.name);
record.cached = true;
req->OnLookupComplete(&record);
return true;
@@ -446,7 +447,7 @@ class MyManager final
ResourceRecord& rr = r.answers.front();
// Set TTL to what we've determined to be the lowest
rr.ttl = cachettl;
- ServerInstance->Logs.Debug(MODNAME, "cache: added cache for " + rr.name + " -> " + rr.rdata + " ttl: " + ConvToStr(rr.ttl));
+ ServerInstance->Logs.Debug(MODNAME, "cache: added cache for {} -> {} ttl: {}", rr.name, rr.rdata, rr.ttl);
this->cache[r.question] = r;
}
@@ -511,7 +512,8 @@ public:
return;
}
- ServerInstance->Logs.Debug(MODNAME, "Processing request to lookup " + req->question.name + " of type " + ConvToStr(req->question.type) + " to " + this->myserver.addr());
+ ServerInstance->Logs.Debug(MODNAME, "Processing request to lookup {} of type {} to {}",
+ req->question.name, (int)req->question.type, this->myserver.addr());
/* Create an id */
unsigned int tries = 0;
@@ -740,7 +742,7 @@ public:
}
else
{
- ServerInstance->Logs.Debug(MODNAME, "Lookup complete for " + request->question.name);
+ ServerInstance->Logs.Debug(MODNAME, "Lookup complete for {}", request->question.name);
this->stats_success++;
request->OnLookupComplete(&recv_packet);
this->AddCache(recv_packet);
diff --git a/src/coremods/core_hostname_lookup.cpp b/src/coremods/core_hostname_lookup.cpp
index 62a7af651..f1f2e1ebc 100644
--- a/src/coremods/core_hostname_lookup.cpp
+++ b/src/coremods/core_hostname_lookup.cpp
@@ -187,7 +187,7 @@ public:
catch (const DNS::Exception& e)
{
delete res_forward;
- ServerInstance->Logs.Debug(MODNAME, "Error in resolver: " + e.GetReason());
+ ServerInstance->Logs.Debug(MODNAME, "Error in resolver: {}", e.GetReason());
HandleError(user, "There was an internal error resolving your host");
}
@@ -236,7 +236,7 @@ public:
{
this->dnsLookup.Unset(user);
delete res_reverse;
- ServerInstance->Logs.Debug(MODNAME, "Error in resolver: " + e.GetReason());
+ ServerInstance->Logs.Debug(MODNAME, "Error in resolver: {}", e.GetReason());
}
}