[eggheads-patches] PATCH: logfile-suffix.diff

Tothwolf tothwolf at concentric.net
Sun Oct 3 13:42:49 CST 1999


logfile-suffix.diff - adds logfile-suffix option.
-------------- next part --------------
Index: eggdrop.conf.dist
===================================================================
RCS file: /usr/local/cvsroot/eggdrop1.3/eggdrop.conf.dist,v
retrieving revision 1.29
diff -u -r1.29 eggdrop.conf.dist
--- eggdrop.conf.dist	1999/09/30 21:08:30	1.29
+++ eggdrop.conf.dist	1999/10/03 00:13:09
@@ -111,6 +111,44 @@
 # be careful with this!)
 set keep-all-logs 0
 
+# Use this suffix for logfiles if keep-all-logs is set.
+# This uses the standard strftime formatting parameters.
+# from the strftime(3) manpage:
+#   %a - abbreviated weekday name according to the current locale
+#   %A - full weekday name according to the current locale
+#   %b - abbreviated month name according to the current locale
+#   %B - full month name according to the current locale
+#   %c - preferred date and time representation for the current locale
+#   %d - day of the month as a decimal number (range 01 to 31)
+#   %H - hour as a decimal number using a 24-hour  clock (range 00 to 23)
+#   %I - hour as a decimal number using a 12-hour clock (range 01 to 12)
+#   %j - day of the year as a decimal number (range  001 to 366)
+#   %m - month as a decimal number (range 01 to 12).
+#   %M - minute as a decimal number.
+#   %p - either `am' or `pm' according to the given time value,
+#        or the corresponding strings for the current locale.
+#   %S - second as a decimal number
+#   %U - week number of the current year as a decimal number, starting
+#        with the first Sunday as the first day of the first week
+#   %W - week number of the current year as a decimal number, starting
+#        with the first Monday as the first day of the first week
+#   %w - day of the week as a decimal, Sunday being 0
+#   %x - preferred date representation for the current locale
+#        without the time
+#   %X - The preferred time representation for the current locale
+#        without the date
+#   %y - year as a decimal number without a century (range 00 to 99)
+#   %Y - year as a decimal number including the century
+#   %Z - time zone or name or abbreviation
+#   %% - a literal `%' character
+#
+# NOTES:
+#        Whitespace in this string will be converted to an underscore.
+#        _Do Not_ use %c, %H, %I, %M, %p, %S, %x, or %X unless you
+#        *REALLY* understand what you are doing!
+#        If you set this to "", logs will *NEVER* be switched out!
+set logfile-suffix ".%d%b%y"
+
 # once a day the logfiles are switched out and started fresh --
 # this specifies when that should happen (in military time)
 # [note that a leading 0 will make Tcl think this is an octal value,
Index: doc/UPDATES1.3
===================================================================
RCS file: /usr/local/cvsroot/eggdrop1.3/doc/UPDATES1.3,v
retrieving revision 1.167
diff -u -r1.167 UPDATES1.3
--- doc/UPDATES1.3	1999/10/02 22:31:10	1.167
+++ doc/UPDATES1.3	1999/10/03 00:13:23
@@ -4,6 +4,7 @@
 
 1.3.29
 Foundby   Fixedby   What....
+          Tothwolf  added logfile-suffix option.
           dw        it said 'JOIN flood from @%s!  Banning.'
                     for nick floods.
 reddawg   rtc       md5 make could fail on some OS
Index: src/eggdrop.h
===================================================================
RCS file: /usr/local/cvsroot/eggdrop1.3/src/eggdrop.h,v
retrieving revision 1.6
diff -u -r1.6 eggdrop.h
--- src/eggdrop.h	1999/09/26 23:14:24	1.6
+++ src/eggdrop.h	1999/10/03 00:13:26
@@ -40,7 +40,7 @@
 #define NICKMAX       15	/* valid values HANDLEN->32 */
 #define UHOSTLEN     161	/* reasonable, i think? */
 #define DIRLEN       256	/* paranoia */
-#define MAX_LOG_LINE (767)	/* for misc.c/putlog() <cybah> */
+#define MAX_LOG_LINE 767	/* for misc.c/putlog() <cybah> */
 
 #define NICKLEN		NICKMAX + 1
 #define NOTENAMELEN     ((HANDLEN * 2) + 1)
Index: src/main.c
===================================================================
RCS file: /usr/local/cvsroot/eggdrop1.3/src/main.c,v
retrieving revision 1.13
diff -u -r1.13 main.c
--- src/main.c	1999/09/26 23:14:24	1.13
+++ src/main.c	1999/10/03 00:13:30
@@ -418,7 +418,7 @@
       call_hook(HOOK_5MINUTELY);
       check_botnet_pings();
       context;
-      if (quick_logs == 0) {
+      if (!quick_logs) {
 	flushlogs();
 	check_logsize();
       }
@@ -470,7 +470,7 @@
   check_tcl_time(nowtm);
   do_check_timers(&timer);
   context;
-  if (quick_logs != 0) {
+  if (quick_logs) {
     flushlogs();
     check_logsize();
   }
Index: src/misc.c
===================================================================
RCS file: /usr/local/cvsroot/eggdrop1.3/src/misc.c,v
retrieving revision 1.15
diff -u -r1.15 misc.c
--- src/misc.c	1999/09/26 23:14:24	1.15
+++ src/misc.c	1999/10/03 00:13:33
@@ -46,6 +46,7 @@
 extern struct chanset_t *chanset;
 extern time_t now;
 extern char bannerfile[];
+extern char logfile_suffix[];	/* suffix for logfiles */
 
 int shtime = 1;			/* whether or not to display the time
 				 * with console output */
@@ -54,6 +55,7 @@
 int max_logsize = 0;		/* maximum logfile size, 0 for no limit */
 int conmask = LOG_MODES | LOG_CMDS | LOG_MISC;	/* console mask */
 int debug_output = 0;		/* disply output to server to LOG_SERVEROUT */
+char logfile_suffix[81] = ".%d%b%y";	/* suffix for logfiles */
 
 struct help_list {
   struct help_list *next;
@@ -97,10 +99,10 @@
     logs[last].filename = logs[last].chname = NULL;
     logs[last].mask = 0;
     logs[last].f = NULL;
-    /*        Added by cybah  */
+    /* Added by cybah */
     logs[last].szLast[0] = 0;
     logs[last].Repeats = 0;
-    /*        Added by rtc  */
+    /* Added by rtc */
     logs[last].flags = 0;
   }
 }
@@ -426,8 +428,7 @@
 {
   int i, type;
   char *format, *chname, s[MAX_LOG_LINE + 1], s1[256], *out;
-  time_t tt;
-  char ct[81];
+  char suffix[81] = "";
   struct tm *T = localtime(&now);
 
   va_list va;
@@ -445,26 +446,8 @@
 #else
   vsprintf(out, format, va);
 #endif
-  tt = now;
-  if (keep_all_logs) {
-    strcpy(ct, ctime(&tt));
-    ct[10] = 0;
-    strcpy(ct, &ct[8]);
-    ct[7] = 0;
-    strcpy(&ct[2], &ct[4]);
-    ct[24] = 0;
-    strcpy(&ct[5], &ct[22]);
-    if (ct[0] == ' ')
-      ct[0] = '0';
-  }
   if ((out[0]) && (shtime)) {
-    strcpy(s1, ctime(&tt));
-    strcpy(s1, &s1[11]);
-    s1[5] = 0;
-    out = s;
-    s[0] = '[';
-    strncpy(&s[1], s1, 5);
-    s[6] = ']';
+    strftime(s, 8, "[%H:%M]", T);
     s[7] = ' ';
   }
   strcat(out, "\n");
@@ -476,7 +459,13 @@
 	if (logs[i].f == NULL) {
 	  /* open this logfile */
 	  if (keep_all_logs) {
-	    sprintf(s1, "%s.%s", logs[i].filename, ct);
+	    if (!logfile_suffix[0]) {
+	      strftime(suffix, sizeof(suffix) - 1, logfile_suffix, T);
+		for (i = 0; i < strlen(suffix); i++)
+		  if (suffix[i] == ' ')
+		    suffix[i] = '_';
+	    }
+	    sprintf(s1, "%s%s", logs[i].filename, suffix);
 	    logs[i].f = fopen(s1, "a+");
 	  } else
 	    logs[i].f = fopen(logs[i].filename, "a+");
@@ -485,7 +474,7 @@
 	  /* Check if this is the same as the last line added to
 	   * the log. <cybah> */
 	  if (!strcasecmp(out + 8, logs[i].szLast)) {
-	    /*      It is a repeat, so increment Repeats */
+	    /* It is a repeat, so increment Repeats */
 	    logs[i].Repeats++;
 	  } else {
 	    /* Not a repeat, check if there were any repeat
@@ -538,7 +527,7 @@
   char buf[1024];		/* should be plenty */
 
   context;
-  if ((keep_all_logs == 0) && (max_logsize != 0)) {
+  if ((!keep_all_logs) && (max_logsize)) {
     for (i = 0; i < max_logs; i++) {
       if (logs[i].filename) {
 	if (stat(logs[i].filename, &ss) != 0) {
Index: src/tcl.c
===================================================================
RCS file: /usr/local/cvsroot/eggdrop1.3/src/tcl.c,v
retrieving revision 1.13
diff -u -r1.13 tcl.c
--- src/tcl.c	1999/09/27 20:33:55	1.13
+++ src/tcl.c	1999/10/03 00:13:37
@@ -41,7 +41,7 @@
 extern int flood_thr, ignore_time;
 extern char origbotname[], botuser[], motdfile[], admin[], userfile[],
  firewall[], helpdir[], notify_new[], hostname[], myip[], moddir[],
- tempdir[], owner[], network[], botnetnick[], bannerfile[];
+ tempdir[], owner[], network[], botnetnick[], bannerfile[], logfile_suffix[];
 extern int die_on_sighup, die_on_sigterm, max_logs, max_logsize, enable_simul;
 extern int dcc_total, debug_output, identtimeout, protect_telnet;
 extern int egg_numver, share_unlinks, dcc_sanitycheck, sort_users;
@@ -378,6 +378,7 @@
 /* confvar patch by aaronwl */
   {"config", configfile, 0, 0},
   {"telnet-banner", bannerfile, 120, STR_PROTECT},
+  {"logfile-suffix", logfile_suffix, 80, STR_PROTECT},
   {0, 0, 0, 0}
 };
 


More information about the Patches mailing list