Răsfoiți Sursa

Add set 'logging' to log to .l-botnick files

Bryan Drewery 6 ani în urmă
părinte
comite
0b07992ab9
5 a modificat fișierele cu 12 adăugiri și 8 ștergeri
  1. 1 0
      doc/help.txt
  2. 2 7
      src/log.cc
  3. 1 0
      src/log.h
  4. 7 0
      src/set.cc
  5. 1 1
      src/set.h

+ 1 - 0
doc/help.txt

@@ -1736,6 +1736,7 @@ See also: reload, backup
                          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'.
+[B]  $blogging$b             Log to .l-botnick files.
 [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 - 7
src/log.cc

@@ -157,8 +157,6 @@ void logidx(int idx, const char *format, ...)
     dprintf(idx, "%s\n", va_out);
 }
 
-#ifdef DEBUG
-/* CURRENTLY SPAWNS TONS OF FILES */
 FILE *log_f;
 bool flush_log = 1;
 bool init_log_exit = 0;
@@ -180,7 +178,7 @@ void logfile_close(void)
 
 bool logfile_open()
 {
-  if (!conf.bot || !conf.bot->nick) return 0;
+  if (!conf.bot || !conf.bot->nick || !logging) return 0;
 
   char filename[20] = "";
   simple_snprintf(filename, sizeof(filename), ".l-%s", conf.bot->nick);
@@ -242,7 +240,6 @@ void logfile(int type, const char *msg)
   if (flush_log)
     fflush(log_f);
 }
-#endif
 
 /* Log something
  * putlog(level,channel_name,format,...);
@@ -308,11 +305,9 @@ void putlog(int type, const char *chname, const char *format, ...)
 
   /* strcat(out, "\n"); */
 
-#ifdef DEBUG
-  /* FIXME: WRITE LOG HERE */
   if (logfile_masks & type)
     logfile(type, out);
-#endif
+
   /* broadcast to hubs */
   if (chname[0] == '*' && conf.bot && conf.bot->nick)
     botnet_send_log(-1, conf.bot->nick, type, out);

+ 1 - 0
src/log.h

@@ -39,6 +39,7 @@ void irc_log(struct chanset_t *, const char *, ...) __attribute__((format(printf
 #define irc_log(...) do {} while (0)
 #endif
 void logfile(int type, const char *msg);
+void logfile_close(void);
 
 extern int		conmask, logfile_masks;
 extern bool		debug_output;

+ 7 - 0
src/set.cc

@@ -54,11 +54,14 @@ int ison_time = 10;
 int kill_threshold;
 int lag_threshold;
 int login;
+bool logging;
 static char logfile_flags_str[100] = "";
 #ifdef DEBUG
 #define LOGFILE_FLAGS_DFL "*"
+#define LOGGING_DFL "1"
 #else
 #define LOGFILE_FLAGS_DFL "mcobeuw"
+#define LOGGING_DFL "0"
 #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
@@ -117,6 +120,7 @@ static variable_t vars[] = {
  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("logging",		&logging,	VAR_INT|VAR_BOOL,					0, 1, LOGGING_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),
@@ -432,6 +436,9 @@ sdprintf("var (mem): %s -> %s", var->name, datain ? datain : "(NULL)");
     }
   } else if (!strcmp(var->name, "logfile-flags")) {
     logfile_masks = logmodes(logfile_flags_str);
+  } else if (!strcmp(var->name, "logging")) {
+    if (!logging)
+      logfile_close();
   }
 
   free(datap);

+ 1 - 1
src/set.h

@@ -70,7 +70,7 @@ typedef struct rate_b {
 extern char		auth_key[], auth_prefix[2], motd[], alias[], rbl_servers[1024], groups[1024],
 			msgident[], msginvite[], msgop[], msgpass[], msgrelease[],
                         homechan[], altchars[];
-extern bool		dccauth, auth_obscure, manop_warn, auth_chan, oidentd, ident_botnick, irc_autoaway, link_cleartext, use_deaf, use_callerid, fish_auto_keyx, fish_paranoid;
+extern bool		dccauth, auth_obscure, manop_warn, auth_chan, oidentd, ident_botnick, irc_autoaway, link_cleartext, use_deaf, use_callerid, fish_auto_keyx, fish_paranoid, logging;
 extern int		cloak_script, fight_threshold, in_bots, set_noshare, dcc_autoaway,
 			kill_threshold, lag_threshold, op_bots, hijack, login, promisc, trace,
                         ison_time, msgrate, msgburst, server_cycle_wait, wait_split;