On Tue, 12 Aug 2003, Evandro Tadeu S Vargas wrote:

> >On Mon, 11 Aug 2003, Lucas Brasilino wrote:
> >
> >> Hi
> >> > I would like change the usual form of date in /var/log/messages to
> >> > another format (like ISO-8601, etc..).
> >> > Anybody help me ?
> >> >
> >> > Thanks in advance.
> >> >
> >> >        Evandro Vargas - IBM Brasil.
> >> >
> >>
> >>         Maybe with a little syslogd source code hacking....
> >>         Or you should configure the desired facility/level to
> >> be written to a named pipe and create a little code to translate
> >> it format to ISO-8601.
> >>
> >
> >You probably don't want to do anything to delay its being written to
> >disk, so if not the source-code hacking, then at display or archive
> >(logrotate) time.
> >
> >I have a little Perl I use to beautify Squid logs; the same approach
> >could be applied to syslog output.
> >
> >The problem with source-code hacking is that, unless you can get your
> >hackery rolled into the master copy, you have that little extra delay in
> >installing any new releases.
>
>
> Thanks guys for response,
>
> John, I would like a copy of your Perl code for study.
>
>              Evandro Vargas - IBM Brasil
>

It's pretty short, so the list can have it.
[EMAIL PROTECTED] summer]$ cat /usr/local/bin/viewsquid
#!/usr/bin/perl
print Scrub(<>);
sub Scrub
   {
      my @data = @_;
      my $Result = "";
      foreach $Datum (@data)
        {
         $Datum =~ tr/+/ /;
         $Datum =~ s=\\r==g;
         $Datum =~ s=\\n=\n=g;
         $Datum =~ s/\r//g;
         $Result .= $Datum;
        }
      #$Posting = tr/+/ / ;
      $Result =~ tr /[]/\n\n/;
      $Result =~ s=\n\n=\n=g;
      $Result =~ s/%(..)/pack("c",hex($1))/ge;
      return $Result ;
   }

[EMAIL PROTECTED] summer]$

Here's the result:
[EMAIL PROTECTED] squid]# tail -1 access.log
1060697155.460    113 numbat.computerdatasafe.com.au TCP_HIT/200 156924 GET 
http://www.rdrop.com/users/billmc/adcomplain.s - NONE/- text/plain [Host: 
www.rdrop.com\r\nUser-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) 
Gecko/20030716 Debian/1.4-2.0.1\r\nAccept: 
text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,video/x-mng,image/png,image/jpeg,image/gif;q=0.2,*/*;q=0.1\r\nAccept-Language:
 en-au,en-us;q=0.7,en;q=0.3\r\nAccept-Encoding: gzip,deflate\r\nAccept-Charset: 
ISO-8859-15,utf-8;q=0.7,*;q=0.7\r\nKeep-Alive: 300\r\nConnection: 
keep-alive\r\nReferer: http://www.rdrop.com/users/billmc/adcomplain.html\r\n] 
[HTTP/1.0 200 OK\r\nAge: 0\r\nDate: Tue, 12 Aug 2003 13:39:09 GMT\r\nContent-Length: 
156548\r\nContent-Type: text/plain\r\nConnection: keep-alive\r\nServer: Apache/1.3.20 
(Unix) mod_jk mod_ssl/2.8.4 OpenSSL/0.9.6\r\nLast-Modified: Wed, 29 Dec 1999 17:02:08 
GMT\r\nETag: "355018-26384-386a3e90"\r\nVia: 1.1 netcache (NetCache NetApp/5.3.1!
R2D4)\r\n\r]
[EMAIL PROTECTED] squid]# tail -1 access.log | viewsquid
1060697155.460    113 numbat.computerdatasafe.com.au TCP_HIT/200 156924 GET 
http://www.rdrop.com/users/billmc/adcomplain.s - NONE/- text/plain
Host: www.rdrop.com
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030716 
Debian/1.4-2.0.1
Accept: text/xml,application/xml,application/xhtml 
xml,text/html;q=0.9,text/plain;q=0.8,video/x-mng,image/png,image/jpeg,image/gif;q=0.2,*/*;q=0.1
Accept-Language: en-au,en-us;q=0.7,en;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-15,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://www.rdrop.com/users/billmc/adcomplain.html

HTTP/1.0 200 OK
Age: 0
Date: Tue, 12 Aug 2003 13:39:09 GMT
Content-Length: 156548
Content-Type: text/plain
Connection: keep-alive
Server: Apache/1.3.20 (Unix) mod_jk mod_ssl/2.8.4 OpenSSL/0.9.6
Last-Modified: Wed, 29 Dec 1999 17:02:08 GMT
ETag: "355018-26384-386a3e90"
Via: 1.1 netcache (NetCache NetApp/5.3.1R2D4)

[EMAIL PROTECTED] squid]#


Actually, you might care to take a decko at the document I was looking at too.





--


Cheers
John.

Join the "Linux Support by Small Businesses" list at
http://mail.computerdatasafe.com.au/mailman/listinfo/lssb
Copyright John Summerfield. Reproduction prohibited.

Reply via email to