Skip to end of metadata
Go to start of metadata

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[

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: 14)

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

]]></ac:plain-text-body></ac:macro>

]]></ac:plain-text-body></ac:macro>

Labels:
None
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Sep 24, 2008

    <p>I like the idea of a shorter way to instantiate loggers and I would welcome a standarized log configuration.</p>

    <p>Some thoughts:</p>

    <ul>
    <li>Stream, Firebug, Syslog and others would easily be configurable this way - but you have to find a solution also fitting Writer_Db and (maybe) Writer_Mail - their constructors currently are asking for objects as their first parameter (Zend_Db_Adapter_Abstract, Zend_Mail)</li>
    <li>I don't like the "enabled" switch - if you want to disable a writer you can remove it from config (or set a comment)</li>
    <li>Better naming: don't set class names, set writer names (stream, db, syslog...)</li>
    <li>Don't forget filters!</li>
    </ul>

    <p>Best regards,<br />
    Thomas Gelf</p>

    1. Oct 03, 2008

      <p>Thanks for your feedback!</p>

      <p>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.</p>

      <p>Wil update in the comming days.</p>

  2. Oct 31, 2008

    <ac:macro ac:name="note"><ac:parameter ac:name="title">Zend Acceptance</ac:parameter><ac:rich-text-body>
    <p>We conditionally approve this for standard incubator.</p>

    <p>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.</p></ac:rich-text-body></ac:macro>

  3. Mar 18, 2009

    <p>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.</p>

  4. Dec 09, 2009

    <p>Code has been committed for review.</p>
    <ul>
    <li><a class="external-link" href="http://framework.zend.com/code/changelog/Zend_Framework?cs=19545">http://framework.zend.com/code/changelog/Zend_Framework?cs=19545</a></li>
    <li><a class="external-link" href="http://framework.zend.com/code/changelog/Zend_Framework?cs=19544">http://framework.zend.com/code/changelog/Zend_Framework?cs=19544</a></li>
    </ul>

    <p>Two points remain:</p>
    <ul>
    <li>Pending a suggestion how to solve the Zend_Log_Writer_Mail</li>
    <li>Documentation needs to be updated.</li>
    </ul>

    1. Dec 23, 2009

      <p>filterParams.priority should accept an array IMHO.</p>

      <p>in config file, user may want to do:</p>

      <p>log.file.filterParams.priority[] = "Zend_Log::CRIT" <br />
      log.file.filterParams.priority[] = "My_Package::CRIT" <br />
      log.file.filterParams.operator = "=="</p>

      <p>See also ZF-8512</p>

    2. Dec 24, 2009

      <p>What about the using a registry-key where the zend_mail instance needs to be ?</p>

  5. Aug 22, 2010

    <p>See ZF-9990 for Zend_Log_Writer_Mail::factory()</p>

  6. Sep 26, 2010

    <p>It's missing formatter options</p>

    <p>should be able to do:<br />
    log.file.formatterName = "Simple"<br />
    log.file.formatterParams.format = "%timestamp% %message%"</p>

    <p>or<br />
    log.file.formatterName = "Xml"<br />
    log.file.formatterParams.rootElement = "log"<br />
    log.file.formatterParams.elementMap.msg = "message"<br />
    log.file.formatterParams.elementMap.level = "priortyName"<br />
    log.file.formatterParams.encoding = "UTF-8"</p>

    <p>See: <a href="http://framework.zend.com/issues/browse/ZF-9176">#ZF-9176</a></p>

    1. Jan 16, 2011

      <p>David, this feature is coming soon (see the comments on the issue <a href="http://framework.zend.com/issues/browse/ZF-9176">ZF-9176</a> or <a href="http://framework.zend.com/issues/browse/ZF-9790">ZF-9790</a>).</p>

  7. Jan 30, 2011

    <p>See <a href="http://framework.zend.com/issues/browse/ZF-10990">ZF-10990</a> to add the support of an option timestampFormat in Zend_Log::factory().</p>

  8. Feb 22, 2011

    <p>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.</p>