Re: [PEPr] Proposal for Logging::Log4P
| From: | Michael Kahn | Date: | Mon, 19 Dec 2005 12:51:06 +0000 |
| Subject: | Re: [PEPr] Proposal for Logging::Log4P | ||
| References: | 1 2 3 4 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-40789@lists.php.net to get a copy of this message | ||
Hi Arnaud:
I use it in a deployed PHP5 production environment currently (as well as a PHP4 environment). The unit tests are in PHPUnit2, so it's developed/tested in PHP5 as well. I develop in a Fedora Core 4 environment.
Someone on the comment page suggested 'Log_Static' as a better package name. I agree, since the current name might draw some flak from the Apache group (at the very least, since I found yet another, unlreated Log4P on the phpclasses site). Though I might personally prefer a more terse package name like 'LogS'--the short name has a certain laziness-appeal that encourages logging. You'll note in the docs that I aliased Log4P::warning() to Log4P::warn() - lazy!
Supposing people do want the name changed - how do I go about doing that once the proposal has been submitted (my own codebase aside)?
MK
Arnaud Limbourg wrote:
... which is an essential way you hook in log4j (well, the way I do it through the Apache Commons Logging interface) in Java. Thus, for PHP I went with a static method approach, and the Log4P class takes care of managing log instances according to the calling class (I see $GLOBALS['log']->debug() type stuff in many codebases, and I don't like it!). Log4P uses a trick that I hope doesn't change in the PHP codebase: if you call a static method from within a PHP object instance, inside the static method $this will still be set to the calling instance. This makes the Log4P approach even easier than Java-style logging, since you can make logging into a one-liner, with no instance binding and configuration separate from your application code:Thanks for the explanation. Have you tested it under PHP5 ? Arnaud.