Zend Framework: Zend_Log Component Proposal
| Proposed Component Name | Zend_Log |
|---|---|
| Developer Notes | http://framework.zend.com/wiki/display/ZFDEV/Zend_Log |
| Proposers | Martin Roest |
| Zend Liaison | Matthew Weier O'Phinney |
| Revision | 1.0 - 29 september 2008: Initial Draft. (wiki revision: 13) |
Table of Contents
1. Overview
This proposition covers a new factory method in Zend_Log that eases the creation and configuration of the Zend_Log object.
2. References
3. Component Requirements, Constraints, and Acceptance Criteria
4. Dependencies on Other Framework Components
- zend_Log_Writer_*
- Zend_Log_Filter_*
5. Theory of Operation
Enable the creation and setup of the Zend_Log object from a Zend_Config object similar the Zend_Db::factory()
A user is able to setup a configuration file with the help of Zend_Config creates the config object and passes the relevant section to the Zend_Log::factory(). The factory method will create the Zend_Log object and adds the configured and enabled log writers.
This allows easy configuration and enable/disable logwriters per config section.
6. Milestones / Tasks
- Milestone 1: Change the log writers to accept a Zend_Config object or Array when constructing the writer
- Milestone 2: Add the factory method
7. Class Index
- Zend_Log
- Zend_Log_Writer_*
- Zend_Log_Filter_*
- Zend_Log_Exception
8. Use Cases
| UC-01 |
|---|
config.ini (The namespace property is only to indicate support for namespace prefix. It defaults to Zend_Log_Writer):
bootstrap/setup
9. Class Skeletons
Zend_Log
Example of how to implement it with the Zend_Log_Writer_Db
12 Comments
comments.show.hideSep 24, 2008
Thomas Gelf
I like the idea of a shorter way to instantiate loggers and I would welcome a standarized log configuration.
Some thoughts:
Best regards,
Thomas Gelf
Oct 03, 2008
Martin Roest
Thanks for your feedback!
I've changed things reflecting your thoughts. Still need some work though. Enabled switch is gone. Classnames are now similar to what Zend_Db does With namespace prefix support to allow inserting your own writers/filters. Added support for filters in the factory.
Wil update in the comming days.
Oct 31, 2008
Matthew Weier O'Phinney
We conditionally approve this for standard incubator.
While we like the idea behind the proposal, we think the implementation could be improved. We would like to see addWriter() and addFilter() modified to allow accepting an array or Zend_Config object – in which cases, it would act as a factory (the factory functionality itself should likely be moved to a protected member). The factory() method itself would then have a much simpler story and fewer concerns.
Mar 18, 2009
Wil Sinclair
What is the status of this proposal? Other changes are happening to Zend_Log for the 1.8 release, and it would be good to see how this fits in.
Dec 09, 2009
Mark van der Velden
Code has been committed for review.
Two points remain:
Dec 23, 2009
Sébastien Debrard
filterParams.priority should accept an array IMHO.
in config file, user may want to do:
log.file.filterParams.priority[] = "Zend_Log::CRIT"
log.file.filterParams.priority[] = "My_Package::CRIT"
log.file.filterParams.operator = "=="
See also ZF-8512
Dec 24, 2009
Benjamin Steininger
What about the using a registry-key where the zend_mail instance needs to be ?
Aug 22, 2010
Benoît Durand
See ZF-9990 for Zend_Log_Writer_Mail::factory()
Sep 26, 2010
David Muir
It's missing formatter options
should be able to do:
log.file.formatterName = "Simple"
log.file.formatterParams.format = "%timestamp% %message%"
or
log.file.formatterName = "Xml"
log.file.formatterParams.rootElement = "log"
log.file.formatterParams.elementMap.msg = "message"
log.file.formatterParams.elementMap.level = "priortyName"
log.file.formatterParams.encoding = "UTF-8"
See: #ZF-9176
Jan 16, 2011
Benoît Durand
David, this feature is coming soon (see the comments on the issue ZF-9176 or ZF-9790).
Jan 30, 2011
Benoît Durand
See ZF-10990 to add the support of an option timestampFormat in Zend_Log::factory().
Feb 22, 2011
Aaron S. Hawley
This class butchers the factory pattern since every module in this package has to itself implement a factory method. Fixing this will require changing many of the writers, formatters and filters to except an array or Zend_Config object for the constructor and reaching for the elegance of Zend_Db's success.