You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by tr...@apache.org on 2007/11/20 20:38:14 UTC
svn commit: r596796 - in /httpd/httpd/trunk: CHANGES support/rotatelogs.c
Author: trawick
Date: Tue Nov 20 11:38:13 2007
New Revision: 596796
URL: http://svn.apache.org/viewvc?rev=596796&view=rev
Log:
Allow local timestamps to be used when rotating based on file size.
IOW, accept and respect either -l or UTC offset when rotating
based on file size.
Modified:
httpd/httpd/trunk/CHANGES
httpd/httpd/trunk/support/rotatelogs.c
Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=596796&r1=596795&r2=596796&view=diff
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Tue Nov 20 11:38:13 2007
@@ -3,7 +3,8 @@
[ When backported to 2.2.x, remove entry from this file ]
*) rotatelogs: Change command-line parsing to report more types
- of errors. [Jeff Trawick]
+ of errors. Allow local timestamps to be used when rotating based
+ on file size. [Jeff Trawick]
*) mod_unique_id: Fix timestamp value in UNIQUE_ID.
PR 37064 [Kobayashi <kobayashi firstserver.co.jp>]
Modified: httpd/httpd/trunk/support/rotatelogs.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/support/rotatelogs.c?rev=596796&r1=596795&r2=596796&view=diff
==============================================================================
--- httpd/httpd/trunk/support/rotatelogs.c (original)
+++ httpd/httpd/trunk/support/rotatelogs.c Tue Nov 20 11:38:13 2007
@@ -67,8 +67,9 @@
fprintf(stderr, "%s\n", reason);
}
fprintf(stderr,
- "Usage: %s [-l] <logfile> <rotation time in seconds> "
- "[offset minutes from UTC] or <rotation size in megabytes>\n\n",
+ "Usage: %s [-l] <logfile> "
+ "{<rotation time in seconds>|<rotation size in megabytes>} "
+ "[offset minutes from UTC]\n\n",
argv0);
#ifdef OS2
fprintf(stderr,
@@ -127,20 +128,14 @@
usage(argv[0], NULL /* specific error message already issued */ );
}
- if (opt->ind + 2 > argc) { /* must have at least a filename and a rotation parameter */
- usage(argv[0], "Too few arguments");
+ if (opt->ind + 2 != argc && opt->ind + 3 != argc) {
+ usage(argv[0], "Incorrect number of arguments");
}
szLogRoot = argv[opt->ind++];
ptr = strchr(argv[opt->ind], 'M');
if (ptr) { /* rotation based on file size */
- if (opt->ind + 1 != argc) {
- usage(argv[0], "Wrong number of arguments for size-based rotation");
- }
- if (use_localtime) {
- usage(argv[0], "-l is not supported with size-based rotation");
- }
if (*(ptr+1) == '\0') {
sRotation = atoi(argv[opt->ind]) * 1048576;
}
@@ -149,20 +144,19 @@
}
}
else { /* rotation based on elapsed time */
- if (opt->ind + 1 != argc && opt->ind + 2 != argc) {
- usage(argv[0], "Wrong number of arguments for time-based rotation");
- }
- if (opt->ind + 2 == argc) {
- if (use_localtime) {
- usage(argv[0], "UTC offset parameter is not valid with -l");
- }
- utc_offset = atoi(argv[opt->ind + 1]) * 60;
- }
tRotation = atoi(argv[opt->ind]);
if (tRotation <= 0) {
usage(argv[0], "Invalid rotation time parameter");
}
}
+ opt->ind++;
+
+ if (opt->ind < argc) { /* have UTC offset */
+ if (use_localtime) {
+ usage(argv[0], "UTC offset parameter is not valid with -l");
+ }
+ utc_offset = atoi(argv[opt->ind]) * 60;
+ }
use_strftime = (strchr(szLogRoot, '%') != NULL);
if (apr_file_open_stdin(&f_stdin, pool) != APR_SUCCESS) {
@@ -219,7 +213,16 @@
tLogStart = (now / tRotation) * tRotation;
}
else {
- tLogStart = (int)apr_time_sec(apr_time_now());
+ if (use_localtime) {
+ /* Check for our UTC offset before using it, since it might
+ * change if there's a switch between standard and daylight
+ * savings time.
+ */
+ apr_time_exp_t lt;
+ apr_time_exp_lt(<, apr_time_now());
+ utc_offset = lt.tm_gmtoff;
+ }
+ tLogStart = (int)apr_time_sec(apr_time_now()) + utc_offset;
}
if (use_strftime) {