[asterisk-commits] jrose: trunk r372976 - in /trunk: configs/logger.conf.sample main/logger.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Sep 12 12:13:07 CDT 2012


Author: jrose
Date: Wed Sep 12 12:13:02 2012
New Revision: 372976

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=372976
Log:
logger: Add rotatestrategy option of 'none' which does not perform rotations

With this option in use, it may be necessary to regulate your log files
externally.

(closes issue ASTERISK-20189)
Reported by: Jaco Kroon
Patches:
    asterisk-logger-norotate-trunk.patch uploaded by Jaco Kroon (license 5671)


Modified:
    trunk/configs/logger.conf.sample
    trunk/main/logger.c

Modified: trunk/configs/logger.conf.sample
URL: http://svnview.digium.com/svn/asterisk/trunk/configs/logger.conf.sample?view=diff&rev=372976&r1=372975&r2=372976
==============================================================================
--- trunk/configs/logger.conf.sample (original)
+++ trunk/configs/logger.conf.sample Wed Sep 12 12:13:02 2012
@@ -40,6 +40,9 @@
 ;queue_log_name = queue_log
 ;
 ; Log rotation strategy:
+; none:  Do not perform any logrotation at all.  You should make
+;        very sure to set up some external logrotate mechanism
+;        as the asterisk logs can get very large, very quickly.
 ; sequential:  Rename archived logs in order, such that the newest
 ;              has the highest sequence number [default].  When
 ;              exec_after_rotate is set, ${filename} will specify

Modified: trunk/main/logger.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/logger.c?view=diff&rev=372976&r1=372975&r2=372976
==============================================================================
--- trunk/main/logger.c (original)
+++ trunk/main/logger.c Wed Sep 12 12:13:02 2012
@@ -92,6 +92,7 @@
 AST_THREADSTORAGE_CUSTOM(unique_callid, NULL, unique_callid_cleanup);
 
 static enum rotatestrategy {
+	NONE = 0,                /* Do not rotate log files at all, instead rely on external mechanisms */
 	SEQUENTIAL = 1 << 0,     /* Original method - create a new file, in order */
 	ROTATE = 1 << 1,         /* Rotate all files, such that the oldest file has the highest suffix */
 	TIMESTAMP = 1 << 2,      /* Append the epoch timestamp onto the end of the archived file */
@@ -427,6 +428,8 @@
 			rotatestrategy = ROTATE;
 		} else if (strcasecmp(s, "sequential") == 0) {
 			rotatestrategy = SEQUENTIAL;
+		} else if (strcasecmp(s, "none") == 0) {
+			rotatestrategy = NONE;
 		} else {
 			fprintf(stderr, "Unknown rotatestrategy: %s\n", s);
 		}
@@ -610,6 +613,9 @@
 	char *suffixes[4] = { "", ".gz", ".bz2", ".Z" };
 
 	switch (rotatestrategy) {
+	case NONE:
+		/* No rotation */
+		break;
 	case SEQUENTIAL:
 		for (x = 0; ; x++) {
 			snprintf(new, sizeof(new), "%s.%d", filename, x);
@@ -810,7 +816,7 @@
 		}
 		if (f->fileptr && (f->fileptr != stdout) && (f->fileptr != stderr)) {
 			int rotate_this = 0;
-			if (ftello(f->fileptr) > 0x40000000) { /* Arbitrarily, 1 GB */
+			if (rotatestrategy != NONE && ftello(f->fileptr) > 0x40000000) { /* Arbitrarily, 1 GB */
 				/* Be more proactive about rotating massive log files */
 				rotate_this = 1;
 			}




More information about the asterisk-commits mailing list