Patch: %m for two-digit month in X-refs
Andrew Ford (andrew@icarus.demon.co.uk)
Sun, 9 Feb 1997 16:20:34 +0100
I find month abbreviations in file names a pain to deal with and have
modified wwwstat to add %m to the syntax of of the -X cross reference
option to represent the two-digit month number (this is consistent
with the date(1)/strftime(3) date formats). The patch is simple and
is appended to this message.
Members of this list who use Apache may also be interested in my
"cronolog" program, which is used to split Apache log files by date.
To quote from the README file:
CRONOLOG
"cronolog" is a simple program that reads log messages from its input
and writes them to a set of output files, the names of which are
constructed using template and the current date and time. The
template uses the same format specifiers as the Unix date command
(which are the same as the standard C strftime library function).
"cronolog" is intended to be used in conjunction with a Web server, such
as Apache to split the access log into daily or monthly logs. For
example the Apache configuration directives:
TransferLog "|/www/sbin/cronolog /www/logs/%Y/%m/%d/access.log"
ErrorLog "|/www/sbin/cronolog /www/logs/%Y/%m/%d/errors.log"
would instruct Apache to pipe its access and error log messages into
separate copies of cronolog, which would create new log files each day
in a directory hierarchy structured by date, i.e. on 31 December 1996
messages would be written to
/www/logs/1996/12/31/access.log
/www/logs/1996/12/31/errors.log
after midnight the files
/www/logs/1997/01/01/access.log
/www/logs/1997/01/01/errors.log
would be used, with the directories 1997, 1997/01 and 1997/01/01 being
created if they did not already exist.
The latest version of Cronolog is at:
http://www.nhbs.co.uk/aford/resources/apache/cronolog/
I am also thinking of modifying wwwstat to generate monthly and day of
the week stats -- anyone interested or forsee any problems?
Andrew
--
Andrew Ford Email: andrew@icarus.demon.co.uk
Independent Software Consultant WWW: http://www.nhbs.co.uk/aford/
"Brittany", Wells Road, Tel: +44 1452 770836
Eastcombe, Stroud, GL6 7EE, GB Fax: +44 1452 770835
*** wwwstat.orig Mon Nov 4 19:06:18 1996
--- wwwstat Sun Feb 2 15:26:00 1997
***************
*** 1463,1470 ****
&output_xref($Do_Ident, $TopIdent, 'Ident', $IdentHeader);
if ($LastSummary) {
! local($prevmonth, $prevyear) = &lastmonth($earliest);
$LastSummary =~ s/%M/$prevmonth/g;
$LastSummary =~ s/%Y/$prevyear/g;
print "<LI><A HREF=\"$LastSummary\">$LastSumHeader</A>\n";
}
--- 1463,1471 ----
&output_xref($Do_Ident, $TopIdent, 'Ident', $IdentHeader);
if ($LastSummary) {
! local($prevmonth, $prevmm, $prevyear) = &lastmonth($earliest);
$LastSummary =~ s/%M/$prevmonth/g;
+ $LastSummary =~ s/%m/$prevmm/g;
$LastSummary =~ s/%Y/$prevyear/g;
print "<LI><A HREF=\"$LastSummary\">$LastSumHeader</A>\n";
}
***************
*** 1919,1926 ****
local($midx) = index($AllMonths, substr($date,0,3));
local($year) = substr($date,7,4);
! if ($midx < 0) { return ('Err', ''); }
! elsif ($midx == 0) { return ('Dec', ($year - 1)); }
! else { return (substr($AllMonths,($midx - 3),3), $year); }
}
--- 1920,1927 ----
local($midx) = index($AllMonths, substr($date,0,3));
local($year) = substr($date,7,4);
! if ($midx < 0) { return ('Err', '', ''); }
! elsif ($midx == 0) { return ('Dec', 12, ($year - 1)); }
! else { return (substr($AllMonths,($midx - 3),3), $midx/3, $year); }
}
*** wwwstat.1.orig Sun Feb 9 15:05:07 1997
--- wwwstat.1 Sun Feb 9 15:05:53 1997
***************
*** 217,226 ****
Use the given string as the HTML title and heading for output.
.TP
.BI \-X " string"
! Use the given string as the cross-reference URL to the last summary output.
! Any occurrence of the characters "%M" or "%Y" are replaced by the month
! and year, respectively, of the month prior to the first log entry date.
! The empty string will exclude any cross-reference.
.TP
.B \-R
Display the daily stats table sorted in reverse. This option is primarily
--- 217,227 ----
Use the given string as the HTML title and heading for output.
.TP
.BI \-X " string"
! Use the given string as the cross-reference URL to the last summary
! output. Any occurrence of the characters "%M", "%m" or "%Y" are
! replaced by the abbreviated month name, the two digit month number and
! the year, respectively, of the month prior to the first log entry
! date. The empty string will exclude any cross-reference.
.TP
.B \-R
Display the daily stats table sorted in reverse. This option is primarily
*** wwwstat.html.orig Sun Feb 9 15:04:59 1997
--- wwwstat.html Sun Feb 9 15:06:48 1997
***************
*** 145,152 ****
<DL COMPACT>
<DT><B>-H</B><I> string</I> <DD>Use the given string as the HTML title and heading for output.
<DT><B>-X</B><I> string</I> <DD>Use the given string as the cross-reference URL to the last summary output.
! Any occurrence of the characters "%M" or "%Y" are replaced by the month
! and year, respectively, of the month prior to the first log entry date.
The empty string will exclude any cross-reference.
<DT><B>-R</B> <DD>Display the daily stats table sorted in reverse. This option is primarily
for use with the
--- 145,154 ----
<DL COMPACT>
<DT><B>-H</B><I> string</I> <DD>Use the given string as the HTML title and heading for output.
<DT><B>-X</B><I> string</I> <DD>Use the given string as the cross-reference URL to the last summary output.
! Any occurrence of the characters "%M", "%m" or
! "%Y" are replaced by the abbreviated month name, the two
! digit month number and the year, respectively, of the month prior to
! the first log entry date.
The empty string will exclude any cross-reference.
<DT><B>-R</B> <DD>Display the daily stats table sorted in reverse. This option is primarily
for use with the