in reply to Poor Man's Web Logger
Nice script! A few notes:
- For better portablity, consider making the "my ISP" IP numbers into variables that can be easily changed at the top, like $home and $logfile are.
- Use the $^T variable instead of calling 'time'
- You could also just say $date=scalar localtime; :)
- Put the gethostbyaddr line before the open and flock. That way, the data can be dumped in very quickly and the file closed again. Even better, write all the data into one variable and have a single print LOG "$data\n"; line between the lock and the close.
- If you can't get to your access logs, the die statement at the end of 'open PIC' does not really help much. On a similar note, you should check the return value of OPEN in 'open LOG' and bypass the rest of the loop if it fails.
- Some servers will report REMOTE_HOST as well as REMOTE_ADDR. If your server is lucky enough to do that, you can remove all the socket stuff!
- Put the "Content-type" line at the start of the script, so the browser knows as early as possible that it is receiving an image.
- You should also tell the browser the size, with a Content-Length header. This info is easily grabbed with -s $pic
- For even better speed, consider hard-coding the image into the script itself. A small gif can be squeezed as small as 35 bytes!
- Output the gif, then do your log file. Not only does the client not have to wait for the log file writing, but you can simply die if 'open LOG' or 'flock LOG' does not work.
- Using all of the above, I can squeeze it down to a 6 line script!
|
---|
Replies are listed 'Best First'. | |
---|---|
RE: RE: Poor Man's Web Logger
by comatose (Monk) on Apr 06, 2000 at 21:53 UTC | |
by btrott (Parson) on Apr 06, 2000 at 22:51 UTC | |
by turnstep (Parson) on Apr 06, 2000 at 22:59 UTC | |
by comatose (Monk) on Apr 06, 2000 at 22:52 UTC | |
by turnstep (Parson) on Apr 06, 2000 at 22:45 UTC |
In Section
Code Catacombs