Преглед изворни кода

Show forwarded message timestamps

Bryan Drewery пре 6 година
родитељ
комит
88cd68fdcf
4 измењених фајлова са 10 додато и 16 уклоњено
  1. 1 0
      doc/UPDATES.md
  2. 2 7
      src/botmsg.cc
  3. 6 8
      src/log.cc
  4. 1 1
      src/tandem.h

+ 1 - 0
doc/UPDATES.md

@@ -15,6 +15,7 @@
   * Tweak server connect burst to progress quicker.
   * Sort cmd_groups and cmd_bots better.
   * cmd_groups: Indicate which bots are down with a _*_.
+  * Logs now include timestamps for forwarded messages.
 
 # maint
   * Clear FiSH keys when a client quits.

+ 2 - 7
src/botmsg.cc

@@ -330,14 +330,9 @@ void putbot(const char *bot, const char *par)
 	 - sends to uplink if a leaf
 	 - sends to all linked hubs if a hub
 */
-void botnet_send_log(int idx, const char *from, int type, const char *msg, bool truncate_ts)
+void botnet_send_log(int idx, const char *from, int type, const char *msg)
 {
-  size_t len;
-  // Cut out timestamp
-  if (truncate_ts)
-    len = simple_snprintf(OBUF, sizeof(OBUF), "lo %s %d %s\n", from, type, &msg[LOG_TS_LEN + 1]); //+1 due to excess space
-  else
-    len = simple_snprintf(OBUF, sizeof(OBUF), "lo %s %d %s\n", from, type, msg);
+  const size_t len = simple_snprintf(OBUF, sizeof(OBUF), "lo %s %d %s\n", from, type, msg);
 
   if (conf.bot->hub) {
     send_hubs_but(idx, OBUF, len);

+ 6 - 8
src/log.cc

@@ -295,18 +295,16 @@ void putlog(int type, const char *chname, const char *format, ...)
   int idx = 0;
   char out[LOGLINEMAX + 1] = "";
 
-  if (conf.bot && conf.bot->hub) {
-    char stamp[34] = "";
+  /* Prepend timestamp into out.  */
+  {
+    char stamp[100];
     time_t synced = now + timesync;
     struct tm *t = gmtime(&synced);
 
     strftime(stamp, sizeof(stamp), LOG_TS, t);
     /* Place the timestamp in the string to be printed */
-    strlcpy(out, stamp, sizeof(out));
-    strlcat(out, " ", sizeof(out));
-    strlcat(out, va_out, sizeof(out));
-  } else
-    strlcpy(out, va_out, sizeof(out));
+    simple_snprintf(out, sizeof(out), "%s %s", stamp, va_out);
+  }
 
   /* strcat(out, "\n"); */
 
@@ -317,7 +315,7 @@ void putlog(int type, const char *chname, const char *format, ...)
 #endif
   /* broadcast to hubs */
   if (chname[0] == '*' && conf.bot && conf.bot->nick)
-    botnet_send_log(-1, conf.bot->nick, type, out, (conf.bot->hub ? 1 : 0));
+    botnet_send_log(-1, conf.bot->nick, type, out);
 
   for (idx = 0; idx < dcc_total; idx++) {
     if (dcc[idx].type && (dcc[idx].type == &DCC_CHAT && dcc[idx].simul == -1) && (dcc[idx].u.chat->con_flags & type)) {

+ 1 - 1
src/tandem.h

@@ -61,7 +61,7 @@ void botnet_send_link(int, const char *, const char *, const char *);
 void botnet_send_update(int, tand_t *);
 void botnet_send_nlinked(int, const char *, const char *, const char, int, time_t, const char *, const char *, int);
 void botnet_send_reject(int, const char *, const char *, const char *, const char *, const char *);
-void botnet_send_log(int, const char *, int, const char *, bool = 0);
+void botnet_send_log(int, const char *, int, const char *);
 void botnet_send_zapf(int, const char *, const char *, const char *);
 void botnet_send_zapf_broad(int, const char *, const char *, const char *);
 void botnet_send_away(int, const char *, int, const char *, int);