Skip to content

Commit

Permalink
clean up server CN logging
Browse files Browse the repository at this point in the history
  • Loading branch information
sauerbraten committed Mar 17, 2022
1 parent b2bbcdc commit 41ab2f4
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
17 changes: 14 additions & 3 deletions patches/serverlogging.patch
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@ Index: src/engine/server.cpp
while(carry < len)
{
size_t numu = encodeutf8(ubuf, sizeof(ubuf)-1, &((const uchar *)buf)[carry], len - carry, &carry);
@@ -339,8 +339,8 @@ void disconnect_client(int n, int reason)
delclient(clients[n]);
const char *msg = disconnectreason(reason);
string s;
- if(msg) formatstring(s, "client (%s) disconnected because: %s", clients[n]->hostname, msg);
- else formatstring(s, "client (%s) disconnected", clients[n]->hostname);
+ if(msg) formatstring(s, "client %s (cn %d) disconnected because: %s", clients[n]->hostname, n, msg);
+ else formatstring(s, "client %s (cn %d) disconnected", clients[n]->hostname, n);
logoutf("%s", s);
server::sendservmsg(s);
}
@@ -661,7 +675,7 @@
c.peer->data = &c;
string hn;
Expand Down Expand Up @@ -72,19 +83,19 @@ Index: src/fpsgame/server.cpp
+ if(authdesc && authdesc[0])
+ {
+ formatstring(msg, "%s claimed %s as '\fs\f5%s\fr' [\fs\f0%s\fr]", colorname(ci), name, authname, authdesc);
+ if(isdedicatedserver()) logoutf("privilege: %s (cn: %d) claimed %s as '%s' [%s]", ci->name, ci->clientnum, name, authname, authdesc);
+ if(isdedicatedserver()) logoutf("privilege: %s (cn %d) claimed %s as '%s' [%s]", ci->name, ci->clientnum, name, authname, authdesc);
}
- else formatstring(msg, "%s %s %s", colorname(ci), val ? "claimed" : "relinquished", name);
+ else
+ {
+ formatstring(msg, "%s claimed %s as '\fs\f5%s\fr'", colorname(ci), name, authname);
+ if(isdedicatedserver()) logoutf("privilege: %s (cn: %d) claimed %s as '%s'", ci->name, ci->clientnum, name, authname);
+ if(isdedicatedserver()) logoutf("privilege: %s (cn %d) claimed %s as '%s'", ci->name, ci->clientnum, name, authname);
+ }
+ }
+ else
+ {
+ formatstring(msg, "%s %s %s", colorname(ci), val ? "claimed" : "relinquished", name);
+ if(isdedicatedserver()) logoutf("privilege: %s (cn: %d) %s %s", ci->name, ci->clientnum, val ? "claimed" : "relinquished", name);
+ if(isdedicatedserver()) logoutf("privilege: %s (cn %d) %s %s", ci->name, ci->clientnum, val ? "claimed" : "relinquished", name);
+ }
packetbuf p(MAXTRANS, ENET_PACKET_FLAG_RELIABLE);
putint(p, N_SERVMSG);
Expand Down
4 changes: 2 additions & 2 deletions src/engine/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,8 @@ void disconnect_client(int n, int reason)
delclient(clients[n]);
const char *msg = disconnectreason(reason);
string s;
if(msg) formatstring(s, "client (%s) disconnected because: %s", clients[n]->hostname, msg);
else formatstring(s, "client (%s) disconnected", clients[n]->hostname);
if(msg) formatstring(s, "client %s (cn %d) disconnected because: %s", clients[n]->hostname, n, msg);
else formatstring(s, "client %s (cn %d) disconnected", clients[n]->hostname, n);
logoutf("%s", s);
server::sendservmsg(s);
}
Expand Down
6 changes: 3 additions & 3 deletions src/fpsgame/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1185,18 +1185,18 @@ namespace server
if(authdesc && authdesc[0])
{
formatstring(msg, "%s claimed %s as '\fs\f5%s\fr' [\fs\f0%s\fr]", colorname(ci), name, authname, authdesc);
if(isdedicatedserver()) logoutf("privilege: %s (cn: %d) claimed %s as '%s' [%s]", ci->name, ci->clientnum, name, authname, authdesc);
if(isdedicatedserver()) logoutf("privilege: %s (cn %d) claimed %s as '%s' [%s]", ci->name, ci->clientnum, name, authname, authdesc);
}
else
{
formatstring(msg, "%s claimed %s as '\fs\f5%s\fr'", colorname(ci), name, authname);
if(isdedicatedserver()) logoutf("privilege: %s (cn: %d) claimed %s as '%s'", ci->name, ci->clientnum, name, authname);
if(isdedicatedserver()) logoutf("privilege: %s (cn %d) claimed %s as '%s'", ci->name, ci->clientnum, name, authname);
}
}
else
{
formatstring(msg, "%s %s %s", colorname(ci), val ? "claimed" : "relinquished", name);
if(isdedicatedserver()) logoutf("privilege: %s (cn: %d) %s %s", ci->name, ci->clientnum, val ? "claimed" : "relinquished", name);
if(isdedicatedserver()) logoutf("privilege: %s (cn %d) %s %s", ci->name, ci->clientnum, val ? "claimed" : "relinquished", name);
}
packetbuf p(MAXTRANS, ENET_PACKET_FLAG_RELIABLE);
putint(p, N_SERVMSG);
Expand Down

0 comments on commit 41ab2f4

Please sign in to comment.