Re: Request For Comments: Log2

From: Date: Sun, 13 Sep 2009 21:47:17 +0000
Subject: Re: Request For Comments: Log2
References: 1 2  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-52806@lists.php.net to get a copy of this message
David, On Sep 13, 2009, at 4:23 PM, David Jean Louis wrote:
Hi Brandon,
All, I spent the weekend implementing a logging class that is based on (but does not implement the API of) the Log class in PEAR. I've completed my initial code writing, and I'd like comments. At the moment, there is no documentation. That is next on my agenda. However, you can browse the code here: http://log2.brandonsavage.net/log2 I've run the code through CodeSniffer and run my unit tests against it, so I think it's largely bug free, but it's always possible that I missed something. Also, suggestions from the community are greatly appreciated.
While I think having a php5 Log2 package that can run with E_STRICT is a very good idea, the code is really far from PEAR::Log in terms of features / flexibility / correctness, just a few points: * interface is not unified (see the Mail driver for example), it is a very bad idea to code driver specific public methods or parameters (what if i change the driver ? do i have to comment those method calls ? change the way i instanciate the driver ? no, the only thing i should have to change is the driver name and maybe some options in an array) * no way to log to console or syslog: this is definitively needed for a log package * no log level masks: this is also needed, it's really helpful * no way to configure the log format (and the date format) * lack of options in drivers: file permissions for the File driver, subject prefix in the mail driver, etc... * no file locking * no shortcuts methods (emerg(), warn()...) * etc... PEAR::Log (even if it's php4) is really well written, well documented[1] and has more than 8 years of debug / user feedback[2], you should really borrow most of the code from it and adapt it to php5. But before that, i think it would be fair to contact Jon Parise (the author of PEAR::Log, maybe you did ?), see what he thinks of the idea and possibly work with him (or ask him to mentor you) to bring a super php5 Log2 package ;) Clearly, my intent is not discourage you on this, i'm just giving you my first impressions :) Cheers ! --David [1] http://www.indelible.org/php/Log/guide.html [2] http://pear.php.net/bugs/search.php?cmd=display&package_name[]=Log&status=All
Thanks for your comments. I do appreciate it and I'm not discouraged. * I'm not sure I understand your concern with regards to driver-specific methods. While it is true that you would have to comment out references like $log->addRecipient(), I would think that the rules of good design would dictate that the Log2 base class has no business containing those methods, as they do not relate to the other drivers. * You're absolutely right. I haven't yet written syslog or console logging, but that was on my list before proposing this for comments. * I missed adding the log level masks, but I will add them. * Configuring the log format and the date format are important, and I will add methods that allow for this before proposing this for comment. * Permissions were excluded from the File driver, as I generally prevent PHP from modifying the file system too much. However, I can see the virtue in having those methods. * You make a good point regarding concurrency. * The shortcut methods were intentionally excluded. I consulted with a number of developers who felt it was silly to have eight methods that were essentially identical, for the sake of typing less. This project came about after I chatted with Chuck Burgess, and is very much a work in progress and not ready for release (and your comments confirm that :-)). Best, Brandon

« previous php.pear.dev (#52806) next »