Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 10 Aug 2007 14:19:55 +0300
From:      Artis Caune <Artis.Caune@latnet.lv>
To:        FreeBSD-hackers@FreeBSD.org
Subject:   [PATCH] newsyslog - don't compress first log file
Message-ID:  <46BC49DB.8060509@latnet.lv>

next in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]
How about aditional flag ("X") to newsyslog, which don't compress first 
log file?
This is useful for apache.




# cat /etc/newsyslog.conf

/var/log/httpd-access.log  www:www  640  64  *  $W1D0  BCZX 
/var/run/httpd.pid  30

# ls /var/log/archive2/
httpd-access.log.0
httpd-access.log.1.gz
httpd-access.log.2.gz
httpd-access.log.3.gz



[-- Attachment #2 --]
--- newsyslog.c.orig	Thu Aug 17 04:20:36 2006
+++ newsyslog.c	Fri Aug 10 13:59:53 2007
@@ -104,6 +104,8 @@
 #define	CE_CREATE	0x0100	/* Create the log file if it does not exist. */
 #define	CE_NODUMP	0x0200	/* Set 'nodump' on newly created log file. */
 
+#define CE_NOCOMPACT1	0x0400  /* Don't compact first log file. */
+
 #define	MIN_PID         5	/* Don't touch pids lower than this */
 #define	MAX_PID		99999	/* was lower, see /usr/include/sys/proc.h */
 
@@ -1228,6 +1230,9 @@
 			case 'z':
 				working->flags |= CE_COMPACT;
 				break;
+			case 'x':
+				working->flags |= CE_NOCOMPACT1;
+				break;
 			case '-':
 				break;
 			case 'f':	/* Used by OpenBSD for "CE_FOLLOW" */
@@ -1498,8 +1503,15 @@
 		 * The zipwork_entry will include a pointer to this
 		 * conf_entry, so the conf_entry should not be freed.
 		 */
-		free_or_keep = KEEP_ENT;
-		save_zipwork(ent, swork, ent->fsize, file1);
+		if (flags & (CE_NOCOMPACT1)) {
+			if (!lstat(file2, &st)) {
+				free_or_keep = KEEP_ENT;
+				save_zipwork(ent, swork, ent->fsize, file2);
+			}
+		} else {
+			free_or_keep = KEEP_ENT;
+			save_zipwork(ent, swork, ent->fsize, file1);
+		}
 	}
 
 	return (free_or_keep);

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?46BC49DB.8060509>