Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

LogScripts.pm

by Fastolfe (Vicar)
on Dec 03, 2000 at 13:13 UTC ( [id://44653]=note: print w/replies, xml ) Need Help??


in reply to tracking files

You may be able to re-associate Perl files in your web server or in NT to a slightly modified Perl command line: "perl.exe -MLogScripts". Then use a module like this to log the start and stop of the script:
package LogScripts; # If you want high-res timekeeping: # use Time::HiRes qw{ time }; my $started; BEGIN { open(F, ">>/logdir/scripts.log"); print F localtime(time) . " $ENV{REMOTE_ADDR} - Starting $0\n"; $started = time(); } END { my $elapsed = time() - $started; print F localtime(time) . " $ENV{REMOTE_ADDR} - Stopping $0 ($elaps +ed seconds)\n"; close(F); }

Replies are listed 'Best First'.
Re: Re: tracking files
by 2501 (Pilgrim) on Dec 04, 2000 at 00:56 UTC
    Thank you all!
    ++'s around for all great answers!
    BBQ : I agree with you, but switching is not an option. Got to deal with the tools you are given sometimes.

    $code_or_die: Very informative! I will definitely check out the software.
    Fastolfe: Perfect! I think that was exactly what I was looking for. I couldn't use $0 because the difference between 90% of the scripts is the script path (and thats about it) so i tweaked it abit to the following:
    package LogScripts; # use Time::HiRes qw{ time }; use File::Spec::Functions qw(rel2abs); my $started; my $path; BEGIN { open(F, ">>c:\\scripts.log"); $path = rel2abs($0); $started = time(); print F localtime(time) . " $ENV{REMOTE_ADDR} - Starting $path\n"; } END { my $elapsed = time() - $started; print F localtime(time) . " $ENV{REMOTE_ADDR} - Stopping $path ($el +apsed seconds)"; close(F); }
    Once again,
    thank you all:) I learned a good deal from everyone.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://44653]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (9)
As of 2024-04-23 13:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found