Ok guys, here she is. Also available at
ftp://ftp.commline.com/pub/unix/Majordomo/
Please take a look at it if you get a chance and let me know if it looks
cool enough to let the majordomo-users have it.
Cheers!
-Brian
CLF type date for Majordomo Logs against Majordomo 1.94.4, v0.1
25 Jan 1998
This patch is to make the Majordomo (1.94.4) log file have CLF type
date and time. If you have the TZ environmental, it will find it and
use it as well, if not, it won't and the time will just be local, as it
is now anyway.
Old format:
Jan 23 15:24:11 krumm.commline.com majordomo[6005] {"Brian L. Heess" <dmbong@commline.com>} help
Jan 23 15:24:11 krumm.commline.com majordomo[6005] {"Brian L. Heess" <dmbong@commline.com>} lists
New format (if you have a TZ):
[25/Jan/1998:21:57:53 EST] commline.com majordomo[17643] {"Brian L. Heess" <dmbong@commline.com>} help
[25/Jan/1998:21:58:08 EST] commline.com majordomo[17651] {"Brian L. Heess" <dmbong@commline.com>} lists
New format (without a TZ):
[25/Jan/1998:21:57:53] commline.com majordomo[17643] {"Brian L. Heess" <dmbong@commline.com>} help
[25/Jan/1998:21:58:08] commline.com majordomo[17651] {"Brian L. Heess" <dmbong@commline.com>} lists
The reason I wrote this is that I have been using the same log for about
40-5 years and for that in reading the log, the dates wrap around at
the new year... :)
So, here we go. Of course, if you use any log readers or anything, they
probably won't work any more. I've been toying with the idea to work on
the log entries a little more to make them totally CLF compatible, which
would then allow those of us using web server log processors to possibly
use them on the Majordomo logs...also, some of the authors of the log
processors may then wish to add code/command processing for Majordomo,
thus giving us cool stats and stuff to look at (like what WebTrends
does for a web log). This info could be VERY powerful as an anlysis
tool!
-Brian L. Heess
brian@commline.com
--- majordomo.pl-orig Thu Jan 22 19:04:35 1998
+++ majordomo.pl Sat Jan 24 07:00:53 1998
@@ -343,20 +343,38 @@
print STDERR "$0: main'log()\n" if $DEBUG;
- local($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime;
+ # Parts of the TZ mod hacked and modifed from ctime.pl
+ # Determine what time zone is in effect.
+ # Use GMT if TZ is defined as null, local time if TZ undefined.
+ # There's no portable way to find the system default timezone.
+ local($TZ) = defined($ENV{'TZ'}) ? ( $ENV{'TZ'} ? $ENV{'TZ'} : 'GMT' ) : '';
+
+ local($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = ($TZ eq 'GMT') ? gmtime : localtime;
local(*MAILMSG);
+ # Hack to deal with 'PST8PDT' format of TZ
+ # Note that this can't deal with all the esoteric forms, but it
+ # does recognize the most common: [:]STDoff[DST[off][,rule]]
+ if($TZ=~/^([^:\d+\-,]{3,})([+-]?\d{1,2}(:\d{1,2}){0,2})([^\d+\-,]{3,})?/){
+ $TZ = $isdst ? $4 : $1;
+ }
+ $TZ = ' ' . $TZ unless $TZ eq '';
+ $year += 1900;
+
+ # make something empty for below
+ local($null) = '';
+
print STDERR "$0: main'log(): opening logfile $log_file\n" if $DEBUG;
if (&main'lopen(LOG, ">>", $log_file)) { #';
# if the log is open, write to the log
- printf LOG "%s %02d %02d:%02d:%02d %s %s[%d] {%s} ",
- $ctime'MoY[$mon], $mday, $hour, $min, $sec,
- $log_host, $log_program, $$, $log_session;
+ printf LOG "[%02d/%s/%04d:%02d:%02d:%02d%s] %s %s[%d] {%s} ",
+ $mday, $ctime'MoY[$mon], $year, $hour, $min, $sec,
+ ($TZ eq '') ? $null : $TZ, $log_host, $log_program, $$, $log_session;
print LOG join(" ", @_), "\n";
&main'lclose(LOG);
} else {
-
+
print STDERR "$0: main'log(): log not open, writing to STDERR and attempting to mail.\n" if $DEBUG;
# otherwise, write to stderr
Follow-Ups:
|
|