[xiph-commits] r10287 - in icecast/trunk/icecast: conf doc src

oddsock at svn.xiph.org oddsock at svn.xiph.org
Mon Oct 24 07:51:56 PDT 2005


Author: oddsock
Date: 2005-10-24 07:51:54 -0700 (Mon, 24 Oct 2005)
New Revision: 10287

Modified:
   icecast/trunk/icecast/conf/icecast.xml.in
   icecast/trunk/icecast/doc/icecast2_config_file.html
   icecast/trunk/icecast/src/cfgfile.c
   icecast/trunk/icecast/src/cfgfile.h
   icecast/trunk/icecast/src/logging.c
   icecast/trunk/icecast/src/main.c
Log:
2 new features to icecast logging:

- logsize : specify in KB the max size of any of icecast log files
- logarchive : causes icecast to rename logs with timestamps (for proper archiving)



Modified: icecast/trunk/icecast/conf/icecast.xml.in
===================================================================
--- icecast/trunk/icecast/conf/icecast.xml.in	2005-10-24 12:27:35 UTC (rev 10286)
+++ icecast/trunk/icecast/conf/icecast.xml.in	2005-10-24 14:51:54 UTC (rev 10287)
@@ -160,6 +160,13 @@
         <errorlog>error.log</errorlog>
         <!-- <playlistlog>playlist.log</playlistlog> -->
       	<loglevel>4</loglevel> <!-- 4 Debug, 3 Info, 2 Warn, 1 Error -->
+      	<logsize>10000</logsize> <!-- Max size of a logfile -->
+        <!-- If logarchive is enabled (1), then when logsize is reached
+             the logfile will be moved to [error|access|playlist].log.DATESTAMP,
+             otherwise it will be moved to [error|access|playlist].log.old.
+             Default is non-archive mode (i.e. overwrite)
+        -->
+        <!-- <logarchive>1</logarchive> -->
     </logging>
 
     <security>

Modified: icecast/trunk/icecast/doc/icecast2_config_file.html
===================================================================
--- icecast/trunk/icecast/doc/icecast2_config_file.html	2005-10-24 12:27:35 UTC (rev 10286)
+++ icecast/trunk/icecast/doc/icecast2_config_file.html	2005-10-24 14:51:54 UTC (rev 10287)
@@ -641,6 +641,18 @@
 <div class="indentedbox">
 Into this file, a log of all metadata for each mountpoint will be written.  The format of the logfile will most likely change over time as we narrow in on a standard format for this.  Currently, the file is pipe delimited.  This option is optional and can be removed entirely from the config file.
 </div>
+<h4>logsize</h4>
+<div class="indentedbox">
+This value specifies (in Kbytes) the maxmimum size of any of the log files.  When the logfile grows beyond this value,
+icecast will either rename it to logfile.old, or add a timestamp to the archived file (if logarchive is enabled).
+</div>
+<h4>logarchive</h4>
+<div class="indentedbox">
+If this value is set, then icecast will append a timestamp to the end of the logfile name when logsize has been reached.
+If disabled, then the default behavior is to rename the logfile to logfile.old (overwriting any previously saved
+logfiles).  We disable this by default to prevent the filling up of filesystems for people who don't care (or know) that 
+their logs are growing.
+</div>
 <h4>loglevel</h4>
 <div class="indentedbox">
 Indicates what messages are logged by icecast.  Log messages are categorized into one of 4 types, Debug, Info, Warn, and Error.<br /><br />The following mapping can be used to set the appropraite value :

Modified: icecast/trunk/icecast/src/cfgfile.c
===================================================================
--- icecast/trunk/icecast/src/cfgfile.c	2005-10-24 12:27:35 UTC (rev 10286)
+++ icecast/trunk/icecast/src/cfgfile.c	2005-10-24 14:51:54 UTC (rev 10287)
@@ -948,10 +948,18 @@
         } else if (strcmp(node->name, "playlistlog") == 0) {
             if (configuration->playlist_log && configuration->playlist_log != CONFIG_DEFAULT_PLAYLIST_LOG) xmlFree(configuration->playlist_log);
             configuration->playlist_log = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
+        } else if (strcmp(node->name, "logsize") == 0) {
+            char *tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
+            configuration->logsize = atoi(tmp);
+            if (tmp) xmlFree(tmp);
         } else if (strcmp(node->name, "loglevel") == 0) {
            char *tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
            configuration->loglevel = atoi(tmp);
            if (tmp) xmlFree(tmp);
+        } else if (strcmp(node->name, "logarchive") == 0) {
+            char *tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
+            configuration->logarchive = atoi(tmp);
+            if (tmp) xmlFree(tmp);
         }
     } while ((node = node->next));
 }

Modified: icecast/trunk/icecast/src/cfgfile.h
===================================================================
--- icecast/trunk/icecast/src/cfgfile.h	2005-10-24 12:27:35 UTC (rev 10286)
+++ icecast/trunk/icecast/src/cfgfile.h	2005-10-24 14:51:54 UTC (rev 10287)
@@ -155,6 +155,8 @@
     char *error_log;
     char *playlist_log;
     int loglevel;
+    int logsize;
+    int logarchive;
 
     int chroot;
     int chuid;

Modified: icecast/trunk/icecast/src/logging.c
===================================================================
--- icecast/trunk/icecast/src/logging.c	2005-10-24 12:27:35 UTC (rev 10286)
+++ icecast/trunk/icecast/src/logging.c	2005-10-24 14:51:54 UTC (rev 10287)
@@ -217,6 +217,8 @@
         snprintf (fn_error, FILENAME_MAX, "%s%s%s", config->log_dir, PATH_SEPARATOR, config->error_log);
         log_set_filename (errorlog, fn_error);
         log_set_level (errorlog, config->loglevel);
+        log_set_trigger (errorlog, config->logsize);
+        log_set_archive_timestamp(errorlog, config->logarchive);
         log_reopen (errorlog);
     }
 
@@ -225,6 +227,8 @@
         char fn_error[FILENAME_MAX];
         snprintf (fn_error, FILENAME_MAX, "%s%s%s", config->log_dir, PATH_SEPARATOR, config->access_log);
         log_set_filename (accesslog, fn_error);
+        log_set_trigger (errorlog, config->logsize);
+        log_set_archive_timestamp(errorlog, config->logarchive);
         log_reopen (accesslog);
     }
 
@@ -233,6 +237,8 @@
         char fn_error[FILENAME_MAX];
         snprintf (fn_error, FILENAME_MAX, "%s%s%s", config->log_dir, PATH_SEPARATOR, config->playlist_log);
         log_set_filename (playlistlog, fn_error);
+        log_set_trigger (errorlog, config->logsize);
+        log_set_archive_timestamp(errorlog, config->logarchive);
         log_reopen (playlistlog);
     }
 }

Modified: icecast/trunk/icecast/src/main.c
===================================================================
--- icecast/trunk/icecast/src/main.c	2005-10-24 12:27:35 UTC (rev 10286)
+++ icecast/trunk/icecast/src/main.c	2005-10-24 14:51:54 UTC (rev 10287)
@@ -194,6 +194,9 @@
         snprintf(fn_error, FILENAME_MAX, "%s%s%s", config->log_dir, PATH_SEPARATOR, config->error_log);
         errorlog = log_open(fn_error);
         log_to_stderr = 0;
+        if (config->logsize)
+            log_set_trigger (errorlog, config->logsize);
+        log_set_archive_timestamp(errorlog, config->logarchive);
     } else {
         errorlog = log_open_file(stderr);
         log_to_stderr = 1;
@@ -213,6 +216,9 @@
         snprintf(fn_access, FILENAME_MAX, "%s%s%s", config->log_dir, PATH_SEPARATOR, config->access_log);
         accesslog = log_open(fn_access);
         log_to_stderr = 0;
+        if (config->logsize)
+            log_set_trigger (accesslog, config->logsize);
+        log_set_archive_timestamp(accesslog, config->logarchive);
     } else {
         accesslog = log_open_file(stderr);
         log_to_stderr = 1;
@@ -239,6 +245,9 @@
             _fatal_error(buf);
         }
         log_to_stderr = 0;
+        if (config->logsize)
+            log_set_trigger (playlistlog, config->logsize);
+        log_set_archive_timestamp(playlistlog, config->logarchive);
     } else {
         playlistlog = -1;
     }



More information about the commits mailing list