diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/inspircd.cpp | 14 | ||||
-rw-r--r-- | src/userprocess.cpp | 17 |
2 files changed, 29 insertions, 2 deletions
diff --git a/src/inspircd.cpp b/src/inspircd.cpp index ee30ba4e9..aa40638e2 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -70,6 +70,7 @@ std::vector<InspSocket*> module_sockets; std::vector<userrec*> local_users; extern int MODCOUNT; +extern char LOG_FILE[MAXBUF]; int openSockfd[MAXSOCKS]; sockaddr_in client,server; socklen_t length; @@ -171,6 +172,7 @@ InspIRCd::InspIRCd(int argc, char** argv) printf("ERROR: Your config file is missing, this IRCd will self destruct in 10 seconds!\n"); Exit(ERROR); } + *LOG_FILE = 0; if (argc > 1) { for (int i = 1; i < argc; i++) { @@ -183,6 +185,18 @@ InspIRCd::InspIRCd(int argc, char** argv) if (!strcmp(argv[i],"-nolimit")) { Config->unlimitcore = true; } + if (!strcmp(argv[i],"-logfile")) { + if (argc > i) + { + strlcpy(LOG_FILE,argv[i+1],MAXBUF); + printf("LOG: Setting logfile to %s",LOG_FILE); + } + else + { + printf("ERROR: The -logfile parameter must be followed by a log file name and path.\n"); + Exit(ERROR); + } + } } } diff --git a/src/userprocess.cpp b/src/userprocess.cpp index fae96721d..c53aaab0b 100644 --- a/src/userprocess.cpp +++ b/src/userprocess.cpp @@ -70,6 +70,7 @@ extern std::vector<InspSocket*> module_sockets; extern time_t TIME; extern time_t OLDTIME; extern std::vector<userrec*> local_users; +char LOG_FILE[MAXBUF]; extern InspIRCd* ServerInstance; extern ServerConfig *Config; @@ -364,9 +365,21 @@ void DoBackgroundUserStuff(time_t TIME) void OpenLog(char** argv, int argc) { - if (Config->logpath == "") + if (!*LOG_FILE) { - Config->logpath = GetFullProgDir(argv,argc) + "/ircd.log"; + if (Config->logpath == "") + { + Config->logpath = GetFullProgDir(argv,argc) + "/ircd.log"; + } + } + else + { + Config->log_file = fopen(LOG_FILE,"a+"); + if (!Config->log_file) + { + printf("ERROR: Could not write to logfile %s, bailing!\n\n",Config->logpath.c_str()); + Exit(ERROR); + } } Config->log_file = fopen(Config->logpath.c_str(),"a+"); if (!Config->log_file) |