Skip to end of metadata
Go to start of metadata

<p>This example shows how to set up a logging feature in your application. You are able to control the level of logging.</p>

<h3>Database initialisation</h3>

<ac:macro ac:name="code"><ac:default-parameter>php</ac:default-parameter><ac:plain-text-body><![CDATA[
$db->query('CREATE TABLE `log` (
`uid` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
`timestamp` VARCHAR(64),
`lvl` VARCHAR(6),
`msg` VARCHAR(256));
');
]]></ac:plain-text-body></ac:macro>

<h3>config.ini</h3>

<ac:macro ac:name="code"><ac:plain-text-body><![CDATA[
[general]
; Debugging Log level 0 - 7
logLevel = 7
]]></ac:plain-text-body></ac:macro>

<h3>MyPlugin_Logger class</h3>

<ac:macro ac:name="code"><ac:default-parameter>php</ac:default-parameter><ac:plain-text-body><![CDATA[
class MyPlugin_Logger extends Zend_Controller_Plugin_Abstract
{
/**

  • Set up logging
    */
    public function preDispatch(Zend_Controller_Request_Abstract $request)
    Unknown macro: { $logLevel = intval(Zend_Registry}

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

<h3>Example usage</h3>

<ac:macro ac:name="code"><ac:default-parameter>php</ac:default-parameter><ac:plain-text-body><![CDATA[
Zend_Registry::get('logger')->debug('Some Debug Trace!');
Zend_Registry::get('logger')->info('Informational message!');
...
]]></ac:plain-text-body></ac:macro>

Labels:
zend_log zend_log Delete
zend_registry zend_registry Delete
log log Delete
registry registry Delete
plugin plugin Delete
example example Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Feb 22, 2011

    <p>If a value to insert to the table is too large for a column, the wrong type or some other issue, then the log will fail to insert. There needs to be some way to add a Zend_Filter to a Zend_Log_Writer_Db to truncate or smash the data so it still succeeds.</p>