Return-Path: Delivered-To: apache-cvs-archive@hyperreal.org Received: (qmail 16755 invoked by uid 6000); 18 Oct 1997 13:07:46 -0000 Received: (qmail 16732 invoked by uid 161); 18 Oct 1997 13:07:44 -0000 Date: 18 Oct 1997 13:07:44 -0000 Message-ID: <19971018130744.16731.qmail@hyperreal.org> From: coar@hyperreal.org To: apache-cvs@hyperreal.org Subject: cvs commit: apachen/src/support split-logfile Sender: apache-cvs-owner@apache.org Precedence: bulk Reply-To: new-httpd@apache.org coar 97/10/18 06:07:44 Modified: src CHANGES Added: src/support split-logfile Log: Bwahaha! Here it is, committed as threatened after the 1.3b2 tarbal: the sample access_log splitter. Revision Changes Path 1.468 +5 -0 apachen/src/CHANGES Index: CHANGES =================================================================== RCS file: /export/home/cvs/apachen/src/CHANGES,v retrieving revision 1.467 retrieving revision 1.468 diff -u -r1.467 -r1.468 --- CHANGES 1997/10/17 13:37:27 1.467 +++ CHANGES 1997/10/18 13:07:42 1.468 @@ -1,5 +1,10 @@ Changes with Apache 1.3b3 + *) New support tool: src/support/split-logfile, a sample Perl script which + splits up a combined access log into separate files based on the + name of the virtual host (listed first in the log records by "%v"). + [Ken Coar] + Changes with Apache 1.3b2 (there is no 1.3b1) *) TestCompile was not passing $LIBS [Dean Gaudet] 1.1 apachen/src/support/split-logfile Index: split-logfile =================================================================== #!/usr/local/bin/perl # # ==================================================================== # Copyright (c) 1995-1997 The Apache Group. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # 3. All advertising materials mentioning features or use of this # software must display the following acknowledgment: # "This product includes software developed by the Apache Group # for use in the Apache HTTP server project (http://www.apache.org/)." # # 4. The names "Apache Server" and "Apache Group" must not be used to # endorse or promote products derived from this software without # prior written permission. For permission please contact # Apache@Apache.Org. # # 5. Redistributions of any form whatsoever must retain the following # acknowledgment: # "This product includes software developed by the Apache Group # for use in the Apache HTTP server project (http://www.apache.org/)." # # THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY # EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE GROUP OR # ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED # OF THE POSSIBILITY OF SUCH DAMAGE. # ==================================================================== # # This software consists of voluntary contributions made by many # individuals on behalf of the Apache Group and was originally based # on public domain software written at the National Center for # Supercomputing Applications, University of Illinois, Urbana-Champaign. # For more information on the Apache Group and the Apache HTTP server # project, please see . # # # This script will take a combined Web server access # log file and break its contents into separate files. # It assumes that the first field of each line is the # virtual host identity (put there by "%v"), and that # the logfiles should be named that+".log" in the current # directory. # # The combined log file is read from stdin. Records read # will be appended to any existing log files. # %is_open = (); while ($log_line = ) { # # Get the first token from the log record; it's the # identity of the virtual host to which the record # applies. # ($vhost) = split (/\s/, $log_line); # # Normalize the virtual host name to all lowercase. # If it's blank, the request was handled by the default # server, so supply a default name. This shouldn't # happen, but caution rocks. # $vhost = lc ($vhost) or "access"; # # If the log file for this virtual host isn't opened # yet, do it now. # if (! $is_open{$vhost}) { open $vhost, ">>${vhost}.log" or die ("Can't open ${vhost}.log"); $is_open{$vhost} = 1; } # # Strip off the first token (which may be null in the # case of the default server), and write the edited # record to the current log file. # $log_line =~ s/^\S*\s+//; printf $vhost "%s", $log_line; } exit 0;