]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Slight optimisation to config reader, looks nicer even if it's not faster.
authorom <om@e03df62e-2008-0410-955e-edbf42e46eb7>
Fri, 7 Apr 2006 12:21:11 +0000 (12:21 +0000)
committerom <om@e03df62e-2008-0410-955e-edbf42e46eb7>
Fri, 7 Apr 2006 12:21:11 +0000 (12:21 +0000)
Make ./inspircd script use -nolog (it already used -debug, which didn't exist until now!?)
Add commandline options -nolog and -debug, -debug forces all log messages to be output regardless of level. -nolog stops the logfile
being written, so you can run with -debug without filling up your disk.
make clean && make install, apparently some of the core doesn't depend on inspircd_io.h in the makefiles..so it'll probably segfault if
you don't.

git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3841 e03df62e-2008-0410-955e-edbf42e46eb7

.inspircd.inc
include/inspircd_io.h
src/helperfuncs.cpp
src/inspircd.cpp
src/inspircd_io.cpp

index cca512a97734aa2a495ad58a0ba8031e04d9d6f2..03be874c69c669059990fbe85f0c63158fd8dfd5 100644 (file)
@@ -91,7 +91,7 @@ sub debug {
         # Check to see its not 'running' already.
         if (getstatus() == 1) { print "InspIRCd is already running.\n"; return 0; }
         # If we are still alive here.. Try starting the IRCd..
-        system("gdb --command=.gdbargs --args $binpath/$executable -nofork -debug");
+        system("gdb --command=.gdbargs --args $binpath/$executable -nofork -debug -nolog");
 }
 
 
index a9de2991744b5c98a2f3d7678584a28c93da7dad..aac40337ddcce4e790c932b53fa8652a152c8a17 100644 (file)
@@ -163,7 +163,7 @@ class ServerConfig : public classbase
         * overridden in the configuration file via
         * the <options> tag.
         */
-        char ModPath[1024];
+       char ModPath[1024];
 
        /** The temporary directory where modules are copied
         */
@@ -172,7 +172,7 @@ class ServerConfig : public classbase
        /** The full pathname to the executable, as
         * given in argv[0] when the program starts.
         */
-        char MyExecutable[1024];
+       char MyExecutable[1024];
 
        /** The file handle of the logfile. If this
         * value is NULL, the log file is not open,
@@ -180,24 +180,42 @@ class ServerConfig : public classbase
         * startup (this should not happen in normal
         * operation!).
         */
-        FILE *log_file;
+       FILE *log_file;
 
        /** If this value is true, the owner of the
         * server specified -nofork on the command
         * line, causing the daemon to stay in the
         * foreground.
         */
-        bool nofork;
+       bool nofork;
+       
+       /** If this value if true then all log
+        * messages will be output, regardless of
+        * the level given in the config file.
+        * This is set with the -debug commandline
+        * option.
+        */
+       bool forcedebug;
+       
+       /** If this is true then log output will be
+        * written to the logfile. This is the default.
+        * If you put -nolog on the commandline then
+        * the logfile will not be written.
+        * This is meant to be used in conjunction with
+        * -debug for debugging without filling up the
+        * hard disk.
+        */
+       bool writelog;
 
        /** If this value is true, halfops have been
         * enabled in the configuration file.
         */
-        bool AllowHalfop;
+       bool AllowHalfop;
 
        /** The number of seconds the DNS subsystem
         * will wait before timing out any request.
         */
-        int dns_timeout;
+       int dns_timeout;
 
        /** The size of the read() buffer in the user
         * handling code, used to read data into a user's
index 034976fb74a84bd67b820ae50ef3a082e14f2777..46a85da2cd1bbde36455b4ed5e0d91b59754a55d 100644 (file)
@@ -77,7 +77,8 @@ void log(int level, char *text, ...)
        va_list argsPtr;
        char textbuffer[MAXBUF];
 
-       if (level < Config->LogLevel)
+       /* If we were given -debug we output all messages, regardless of configured loglevel */
+       if ((level < Config->LogLevel) && !Config->forcedebug)
                return;
 
        if (TIME != LAST)
@@ -95,13 +96,13 @@ void log(int level, char *text, ...)
                vsnprintf(textbuffer, MAXBUF, text, argsPtr);
                va_end(argsPtr);
 
-               if (Config->log_file)
+               if (Config->writelog)
                        fprintf(Config->log_file,"%s %s\n",TIMESTR,textbuffer);
-
-               if (Config->nofork)
-               {
-                       printf("%s %s\n", TIMESTR, textbuffer);
-               }
+       }
+       
+       if (Config->nofork)
+       {
+               printf("%s %s\n", TIMESTR, textbuffer);
        }
 }
 
index 5d77e6d7532dba400a779b0ef7c215c440c4ab29..79a6f1976cdee65f26a817cd1694ad7cd649ac9b 100644 (file)
@@ -171,15 +171,23 @@ InspIRCd::InspIRCd(int argc, char** argv)
                        {
                                Config->nofork = true;
                        }
-                       if (!strcmp(argv[i],"-wait"))
+                       else if(!strcmp(argv[i],"-debug"))
+                       {
+                               Config->forcedebug = true;
+                       }
+                       else if(!strcmp(argv[i],"-nolog"))
+                       {
+                               Config->writelog = false;
+                       }
+                       else if (!strcmp(argv[i],"-wait"))
                        {
                                sleep(6);
                        }
-                       if (!strcmp(argv[i],"-nolimit"))
+                       else if (!strcmp(argv[i],"-nolimit"))
                        {
                                printf("WARNING: The `-nolimit' option is deprecated, and now on by default. This behaviour may change in the future.\n");
                        }
-                       if (!strcmp(argv[i],"-logfile"))
+                       else if (!strcmp(argv[i],"-logfile"))
                        {
                                if (argc > i+1)
                                {
@@ -867,4 +875,3 @@ int main(int argc, char** argv)
        }
        return 0;
 }
-
index 9753e182ebb9ef511db8aeb01b433eed1ba2efce..ddad3d38805b70f600a4e73993d166d904846882 100644 (file)
@@ -52,8 +52,8 @@ ServerConfig::ServerConfig()
        *CustomVersion = *motd = *rules = *PrefixQuit = *DieValue = *DNSServer = '\0';
        *OperOnlyStats = *ModPath = *MyExecutable = *DisabledCommands = *PID = '\0';
        log_file = NULL;
-       OperSpyWhois = nofork = HideBans = HideSplits = false;
-       AllowHalfop = true;
+       forcedebug = OperSpyWhois = nofork = HideBans = HideSplits = false;
+       writelog = AllowHalfop = true;
        dns_timeout = DieDelay = 5;
        MaxTargets = 20;
        NetBufferSize = 10240;
@@ -1320,7 +1320,7 @@ bool ServerConfig::ConfValueBool(ConfigDataHash &target, const std::string &tag,
        
 int ServerConfig::ConfValueEnum(ConfigDataHash &target, const char* tag)
 {
-       return ConfValueEnum(target, std::string(tag));
+       return target.count(tag);
 }
 
 int ServerConfig::ConfValueEnum(ConfigDataHash &target, const std::string &tag)