From b9d9a9feaea1dc9a730c2772251ca1cbcf2a7249 Mon Sep 17 00:00:00 2001 From: ac_stef Date: Thu, 18 Dec 2008 19:01:59 +0000 Subject: [PATCH] new commandline parameter to set the log identity git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@4038 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- docs/commandline.html | 10 ++++++++++ source/src/main.cpp | 5 +++-- source/src/protos.h | 2 +- source/src/server.cpp | 11 +++++++---- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/docs/commandline.html b/docs/commandline.html index 0432d7c7..f8aa6833 100644 --- a/docs/commandline.html +++ b/docs/commandline.html @@ -313,6 +313,16 @@ -f28765 for a second server. + + + -NID + + + Sets the log identity to ID. By default, the log identity is 'IP[port]'. On linux systems, + the log identity is used for the syslog to identify server log entries. On windows and + apple systems, the log identity is used to create the server logfile filename. + + -mM diff --git a/source/src/main.cpp b/source/src/main.cpp index 510f4e89..ef796fb2 100644 --- a/source/src/main.cpp +++ b/source/src/main.cpp @@ -566,7 +566,7 @@ int main(int argc, char **argv) bool dedicated = false; int uprate = 0, maxcl = DEFAULTCLIENTS, kthreshold = -5, bthreshold = -6, port = 0, permdemo = -1; - const char *sdesc = "", *sdesc_pre = "", *sdesc_suf = "", *ip = "", *master = NULL, *passwd = "", *maprot = NULL, *adminpwd = NULL, *pwdfile = NULL, *blfile = NULL, *srvmsg = NULL, *demop = NULL; + const char *sdesc = "", *sdesc_pre = "", *sdesc_suf = "", *ip = "", *logident = NULL, *master = NULL, *passwd = "", *maprot = NULL, *adminpwd = NULL, *pwdfile = NULL, *blfile = NULL, *srvmsg = NULL, *demop = NULL; static string voteperms; voteperms[0] = '\0'; pushscontext(IEXC_CFG); @@ -618,6 +618,7 @@ int main(int argc, char **argv) } break; case 'i': ip = a; break; + case 'N': logident = a; break; case 'm': master = a; break; case 'p': passwd = a; break; case 'r': maprot = a; break; @@ -654,7 +655,7 @@ int main(int argc, char **argv) if(enet_initialize()<0) fatal("Unable to initialise network module"); initclient(); - initserver(dedicated, uprate, sdesc, sdesc_pre, sdesc_suf, ip, port, master, passwd, maxcl, maprot, adminpwd, pwdfile, blfile, srvmsg, kthreshold, bthreshold, permdemo, voteperms, demop); // never returns if dedicated + initserver(dedicated, uprate, sdesc, sdesc_pre, sdesc_suf, ip, port, logident, master, passwd, maxcl, maprot, adminpwd, pwdfile, blfile, srvmsg, kthreshold, bthreshold, permdemo, voteperms, demop); // never returns if dedicated initlog("world"); empty_world(7, true); diff --git a/source/src/protos.h b/source/src/protos.h index 70519a72..90254ad4 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -665,7 +665,7 @@ extern const char *modestr(int n, bool acronyms = false); extern const char *voteerrorstr(int n); extern const char *mmfullname(int n); extern void fatal(const char *s, ...); -extern void initserver(bool dedicated, int uprate, const char *sdesc, const char *sdesc_pre, const char *sdesc_suf, const char *ip, int serverport, const char *master, const char *passwd, int maxcl, const char *maprot, const char *adminpwd, const char *pwdfile, const char *blfile, const char *srvmsg, int kthreshold, int bthreshold, int permdemo, const char *voteperms, const char *demop); +extern void initserver(bool dedicated, int uprate, const char *sdesc, const char *sdesc_pre, const char *sdesc_suf, const char *ip, int serverport, const char *logident, const char *master, const char *passwd, int maxcl, const char *maprot, const char *adminpwd, const char *pwdfile, const char *blfile, const char *srvmsg, int kthreshold, int bthreshold, int permdemo, const char *voteperms, const char *demop); extern void cleanupserver(); extern void localconnect(); extern void localdisconnect(); diff --git a/source/src/server.cpp b/source/src/server.cpp index f12c8b0a..df43829e 100644 --- a/source/src/server.cpp +++ b/source/src/server.cpp @@ -3550,7 +3550,7 @@ void localconnect() } #endif -void initserver(bool dedicated, int uprate, const char *sdesc, const char *sdesc_pre, const char *sdesc_suf, const char *ip, int serverport, const char *master, const char *passwd, int maxcl, const char *maprot, const char *adminpwd, const char *pwdfile, const char *blfile, const char *srvmsg, int kthreshold, int bthreshold, int permdemo, const char *voteperms, const char *demop) +void initserver(bool dedicated, int uprate, const char *sdesc, const char *sdesc_pre, const char *sdesc_suf, const char *ip, int serverport, const char *logident, const char *master, const char *passwd, int maxcl, const char *maprot, const char *adminpwd, const char *pwdfile, const char *blfile, const char *srvmsg, int kthreshold, int bthreshold, int permdemo, const char *voteperms, const char *demop) { srand(time(NULL)); @@ -3569,7 +3569,9 @@ void initserver(bool dedicated, int uprate, const char *sdesc, const char *sdesc s_strcpy(demopath, demop && demop[0] ? demop : ""); motd[0] = '\0'; - s_sprintfd(identity)("%s[%d]", ip && ip[0] ? ip : "local", serverport); + string identity; + if(logident && logident[0]) s_sprintf(identity)("[%s]", logident); + else s_sprintf(identity)("%s[%d]", ip && ip[0] ? ip : "local", serverport); logger = newlogger(identity); if(dedicated) logger->open(); // log on ded servers only logger->writeline(log::info, "logging local AssaultCube server now.."); @@ -3644,7 +3646,7 @@ int main(int argc, char **argv) #endif int uprate = 0, maxcl = DEFAULTCLIENTS, kthreshold = -5, bthreshold = -6, port = 0, permdemo = -1; - const char *sdesc = "", *sdesc_pre = "", *sdesc_suf = "", *ip = "", *master = NULL, *passwd = "", *maprot = "", *admpwd = NULL, *pwdfile = NULL, *blfile = NULL, *srvmsg = NULL, *service = NULL, *demop = NULL; + const char *sdesc = "", *sdesc_pre = "", *sdesc_suf = "", *ip = "", *logident = NULL, *master = NULL, *passwd = "", *maprot = "", *admpwd = NULL, *pwdfile = NULL, *blfile = NULL, *srvmsg = NULL, *service = NULL, *demop = NULL; static string voteperms; voteperms[0] = '\0'; for(int i = 1; i