“One recurrent theme in my job as a database
administrator/assistant systems administrator/systems analyst is
the need to keep track of what happened on the systems while I
wasn’t watching. What did the cron job do last night. What did all
those spooler daemons do while I was at lunch? In other words
logging. It bothered me that there was a lack of simple tools for
doing such a simple, redundant job. So, I set out to do build some
myself. My systems programming tool of choice is Perl, so, that is
language I chose for the project. This journey took me out of my
normal routine of straight-line Perl programming and dumped me in
the land of Modules and Object Oriented Perl. I’m glad to say it
didn’t overwhelm me and in fact I found it rather easy to
write.”
“My first order of business was to take my old standby logging
routines and objectify them. I had several concise routines that I
would either import into the main package through a use statement
or just simply copy/paste depending on my mood and what I was
doing. They consisted of four routines: start_logging,
stop_logging, restart_logging and log.”
“This was quick and dirty code that, while it did the job, was
not very simple to use. For example, if I needed to redirect the
output of a sub-process to the log file I would have to say:
stop_logging(), then run that process and redirect its output to
the log then restart_logging() again. It was Rather clumsy and
difficult to document. So, I set about to rewrite the routines in
an object oriented manner. I followed the ‘Three little rules’ as
formulated by Larry Wall in the objperl(1) man page and restated by
Damian Conway in his book “Object Oriented Perl”…”