You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Rich Bowen <rb...@rcbowen.com> on 2002/06/16 04:43:39 UTC
[PATCH] split-logfile script performance
Not to pick too many nits, but this patch applies 2, rather than 3,
regular expressions, to each line of the log file, and so runs 1/3
faster than the earlier version. Yeah, I'm probably being overly picky,
but, I started tinkering, and then benchmarked.
Note that this still does not run under 'use strict;'. I'm not feeling
quite that picky this evening.
Index: split-logfile.in
===================================================================
RCS file: /home/cvs/httpd-2.0/support/split-logfile.in,v
retrieving revision 1.3
diff -B -b -u -r1.3 split-logfile.in
--- split-logfile.in 15 Jun 2002 20:35:14 -0000 1.3
+++ split-logfile.in 16 Jun 2002 02:36:48 -0000
@@ -70,34 +70,39 @@
# identity of the virtual host to which the record
# applies.
#
- ($vhost) = split (/\s/, $log_line);
+ $log_line =~ s/^(\S*)\s+//;
+ $vhost = $1;
#
# 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";
+ $vhost = lc ($vhost) or 'access';
#
# if the vhost contains a "/" or "\", it is illegal so just use
- # the default log to avoid any security issues due if it is interprted
+ # the default log to avoid any security issues if it is interpreted
# as a directory separator.
- if ($vhost =~ m#[/\\]#) { $vhost = "access" }
+ $vhost = 'access' if $vhost =~ m![/\\]!;
#
# 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");
+ unless ( $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.
+ # Write the record to the current log file.
#
- $log_line =~ s/^\S*\s+//;
- printf $vhost "%s", $log_line;
+ print $vhost $log_line;
}
-exit 0;
+
+#
+# Close all open file handles
+#
+foreach $vhost ( keys %is_open ) {
+ close $vhost;
+}
+
Windows digital signature and encryption
Posted by jlwpc1 <jl...@earthlink.net>.
<quote>
announce the general availability
of CAPICOM 2.0, Microsoft's COM
object for developing digital signature
and encryption enabled applications.
</quote>
Capicom 2.0 works in every Windows
OS and is usable with Windows Script
Host 5.6 too - for quick development
or tests!
The release is available for download at
http://www.microsoft.com/downloads/release.asp?ReleaseID=39546
Documentation can always be found on MSDN at:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/secur
ity/security/capicom_reference.asp
JLW
Re: [PATCH] split-logfile script performance
Posted by jlwpc1 <jl...@earthlink.net>.
: Not to pick too many nits, but this patch applies 2, rather than 3,
: regular expressions, to each line of the log file, and so runs 1/3
: faster than the earlier version. Yeah, I'm probably being overly
picky,
: but, I started tinkering, and then benchmarked.
:
For you Windows users, wishing
to try "tinkering" with these ideas,
with the Windows script engine,
Windows Script Host 5.6, using
the command line window, try:
Examples:
>From the Online ( and downloadable )
System Administration Scripting Guide
Logs
http://www.microsoft.com/technet/scriptcenter/logs/default.asp
Files and Folders
http://www.microsoft.com/technet/scriptcenter/filefolder/default.asp
Visual Basic Scripting Edition
Introduction to Regular Expressions
http://msdn.microsoft.com/library/en-us/script56/html/reconIntroductio
nToRegularExpressions.asp
JScript
Introduction to Regular Expressions
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/scrip
t56/html/js56reconIntroductionToRegularExpressions.asp
JLW