Sfoglia il codice sorgente

Add set 'logfile-flags'

Bryan Drewery 6 anni fa
parent
commit
1a2e5ba3f0
4 ha cambiato i file con 15 aggiunte e 8 eliminazioni
  1. 1 0
      doc/help.txt
  2. 2 3
      src/log.cc
  3. 1 1
      src/log.h
  4. 11 4
      src/set.cc

+ 1 - 0
doc/help.txt

@@ -1735,6 +1735,7 @@ See also: reload, backup
 [N]  $bmsgrate$b             How often (msecs) to dequeue msgs to the server. Only used on
                          non-ratbox servers. Too small a value can result in Excess Flood.
 [L]  $bgroups$b              List of groups that the affected bots are a part of.
+[S]  $blogfile-flags$b       Logfile modes. See '%dhelp console'.
 [L]  $brbl-servers$b         Servers to use for RBL checking in channels that are +rbl.
  
 [S]  $brealname$b            The bot's "real name" when connecting. (supports '$n' expansion)

+ 2 - 3
src/log.cc

@@ -49,6 +49,7 @@
 #include <unistd.h>
 
 int	conmask = LOG_MODES | LOG_CMDS | LOG_MISC; /* Console mask */
+int	logfile_masks = 0;      /* Defaults from 'logfile-flags' */
 bool	debug_output = 1;      /* Disply output to server to LOG_SERVEROUT */
 
 typedef struct {
@@ -311,9 +312,7 @@ void putlog(int type, const char *chname, const char *format, ...)
 
 #ifdef DEBUG
   /* FIXME: WRITE LOG HERE */
-  int logfile_masks = LOG_ALL;
-
-  if ((logfile_masks && (logfile_masks & type)) || 1)
+  if (logfile_masks & type)
     logfile(type, out);
 #endif
   /* broadcast to hubs */

+ 1 - 1
src/log.h

@@ -40,7 +40,7 @@ void irc_log(struct chanset_t *, const char *, ...) __attribute__((format(printf
 #endif
 void logfile(int type, const char *msg);
 
-extern int		conmask;
+extern int		conmask, logfile_masks;
 extern bool		debug_output;
 
 #endif /* !_LOG_H */

+ 11 - 4
src/set.cc

@@ -54,6 +54,12 @@ int ison_time = 10;
 int kill_threshold;
 int lag_threshold;
 int login;
+static char logfile_flags_str[100] = "";
+#ifdef DEBUG
+#define LOGFILE_FLAGS_DFL "*"
+#else
+#define LOGFILE_FLAGS_DFL "mcobeuw"
+#endif
 /* Number of seconds to wait between transmitting queued lines to the server
  * lower this value at your own risk.  ircd is known to start flood control
  * at 512 bytes/2 seconds.
@@ -110,6 +116,7 @@ static variable_t vars[] = {
  VAR("kill-threshold",	&kill_threshold,	VAR_INT|VAR_NOLOC,				0, 0, "0"),
  VAR("lag-threshold",	&lag_threshold,		VAR_INT|VAR_NOLHUB,				0, 0, "15"),
  VAR("link_cleartext",	&link_cleartext,	VAR_INT|VAR_NOLOC|VAR_BOOL,			0, 1, "0"),
+ VAR("logfile-flags",	logfile_flags_str,	VAR_STRING,					0, 0, LOGFILE_FLAGS_DFL),
  VAR("login",		&login,			VAR_INT|VAR_DETECTED,				0, 4, "warn"),
  VAR("manop-warn",	&manop_warn,		VAR_INT|VAR_BOOL|VAR_NOLHUB,			0, 1, "1"),
  VAR("motd",		motd,			VAR_STRING|VAR_HIDE|VAR_NOLOC,			0, 0, NULL),
@@ -416,15 +423,15 @@ sdprintf("var (mem): %s -> %s", var->name, datain ? datain : "(NULL)");
     sdprintf("server-use-ssl changed, reprocessing server list");
     variable_t *servers = var_get_var_by_name(get_server_type());
     var_set_mem(servers, servers->ldata ? servers->ldata : servers->gdata);
-  }
-
-  // Check if should part/join channels based on groups changing
-  if (!conf.bot->hub && !strcmp(var->name, "groups")) {
+  } else if (!conf.bot->hub && !strcmp(var->name, "groups")) {
+    // Check if should part/join channels based on groups changing
     if (server_online && !restarting && !loading && !reset_chans) {
       for (struct chanset_t* chan = chanset; chan; chan = chan->next) {
         check_shouldjoin(chan);
       }
     }
+  } else if (!strcmp(var->name, "logfile-flags")) {
+    logfile_masks = logmodes(logfile_flags_str);
   }
 
   free(datap);