DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=24417>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=24417 [PATCH] rotatelogs with local time (including DST) functionality Summary: [PATCH] rotatelogs with local time (including DST) functionality Product: Apache httpd-2.0 Version: 2.0.47 Platform: PC OS/Version: Linux Status: NEW Severity: Enhancement Priority: Other Component: support AssignedTo: [email protected] ReportedBy: [EMAIL PROTECTED] While rotatelogs allows to specify an offset to UTC, it doesn't take DST into account. This sucks if you want to process your (e.g. daily) log file with a cron job immediately afterwards, since cron will take DST into account. The following patch allows to specify the keyword "local" instead of a numerical offset. In this case, rotatelogs will rotate according to the local time, including DST. Example: | rotatelogs /path/to/access_log.%Y%m%d 86400 local I have not yet updated the manpage accordingly; please tell me if I should do so (I'm no native English speaker, though). Here's the patch: --- rotatelogs.c.ORIG 2003-02-03 18:32:09.000000000 +0100 +++ rotatelogs.c 2003-11-04 19:06:30.000000000 +0100 @@ -62,6 +62,10 @@ * Ported to APR by Mladen Turk <[EMAIL PROTECTED]> * * 23 Sep 2001 + * + * Modified to work with local time (including DST) by Uli Zappe <[EMAIL PROTECTED]> + * + * 04 Nov 2003 */ @@ -100,6 +104,7 @@ apr_size_t nRead, nWrite; int use_strftime = 0; int now = 0; + int local = 0; const char *szLogRoot; apr_file_t *f_stdin, *nLogFD = NULL, *nLogFDprev = NULL; apr_pool_t *pool; @@ -149,7 +154,8 @@ } else { if (argc >= 4) { - utc_offset = atoi(argv[3]) * 60; + if (strcmp (argv[3], "local") == 0) local = 1; + else utc_offset = atoi(argv[3]) * 60; } tRotation = atoi(argv[2]); if (tRotation <= 0) { @@ -169,7 +175,15 @@ if (apr_file_read(f_stdin, buf, &nRead) != APR_SUCCESS) exit(3); if (tRotation) { - now = (int)(apr_time_now() / APR_USEC_PER_SEC) + utc_offset; + int offset; + apr_time_t _now = apr_time_now(); + if (local) { + apr_time_exp_t exptime; + apr_time_exp_lt (&exptime, _now); + offset = exptime.tm_gmtoff; + } + else offset = utc_offset; + now = (int)(_now / APR_USEC_PER_SEC) + offset; if (nLogFD != NULL && now >= tLogEnd) { nLogFDprev = nLogFD; nLogFD = NULL; --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
