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,
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;
}
}
}
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) {
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) {