Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Rolling your own die/carp/croak/logging/exception facility

by hv (Prior)
on Mar 10, 2006 at 12:54 UTC ( [id://535687]=note: print w/replies, xml ) Need Help??


in reply to Rolling your own die/carp/croak/logging/exception facility

I use a handrolled system which works very well for my application. I talked about it a bit at Catching fork() with tied STDERR.

While I never did find a general solution for the type of problem I discussed there, it hasn't caused me any problems since I found the solution for Email::Valid (ie to stop it forking by installing Net::DNS).

Until this week I supported 4 levels of logging: die, warn, debug and info. $SIG{__DIE__}, $SIG{__WARN__} are caught to redirect appropriately. Logged messages are split by installation (there are about 50 installations of the application running on the main box), and within an installation 'info' messages go to one file, and all others are split to files named after the program that generated them.

A cron job sends me a nightly email of any nonempty non-info files - the idea is that any problems logged are resolved and then the log lines relating to the problem cleared down, so that most of the time nothing is listed.

There is a single utility (called 'log') that makes it all useful: it allows me to list the log files, search for log lines matching particular patterns, clear down matching log lines, or tail selected groups of log files. (I got help with the tail problem at nonblocking I/O - testing whether file has more data to read - it now happily tails 80-odd files with good responsiveness at a processor load of around 0.07.)

This week I added a new type of log - spammers were regularly coming along to try and find holes in our mailform script, and we wanted a more automated process for handling them that didn't keep generating error logs. So I added an 'abuse' type, logged to a single per-installation file (like info), and a mechanism to block abusers for escalating periods of time.

Hugo

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2024-03-29 11:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found