I am messing around with different PHP logging frameworks. I am currently trying PEAR::Log. I figured that I would use its singleton
function to make sure there was only one instance of the class around.
I have a small daemon-like script I wanted to add logging to because it was probably the simplest script in the system to test. This script has several functions. I will probably want to log things inside the functions.
The question I have is how do I best manage this singleton?
To me calling this:
&Log::singleton($handler, $name, $ident, $conf, $maxLevel);
in every function doesn't seem ideal especially since I already specified all of the options in the initial call. Pear::Log serializes this info, but from what it looks like you still have to provide all of those variables to get the instance.
Another alternative is passing the instance into every function. Again, seems like it's less than ideal.
I suppose you could make the instance a 'global' as well.
What do you in this situation? Are there better solutions?