View Source

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[{zone-template-instance:ZFPROP:Proposal Zone Template}

{zone-data:component-name}
Zend_Log_Writer_Doctrine
{zone-data}

{zone-data:proposer-list}
[Matthew Lurz|mailto:mlurz71@gmail.com]
{zone-data}

{zone-data:liaison}
TBD
{zone-data}

{zone-data:revision}
0.1 - 2 June 2009: Initial Draft.
{zone-data}

{zone-data:overview}
Zend_Log_Writer_Doctrine is a log writer modeled after Zend_Log_Writer_Db for the Doctrine O/RM.

A working prototype is available [here|http://framework.zend.com/wiki/download/attachments/13107682/Doctrine.php]
{zone-data}

{zone-data:references}
* Doctrine_Table

* Zend_Log_Writer_Db
{zone-data}

{zone-data:requirements}
* This component will require a pre-configured Doctrine environment

* This component will write log data to a Doctrine_Table

* This component will allow configuration of column mappings

* This component will not support formatters
{zone-data}

{zone-data:dependencies}
* Zend_Log_Writer_Abstract
{zone-data}

{zone-data:operation}
The constructor of Zend_Log_Writer_Doctrine receives the name of a model class and an array mapping of database columns to event data items.
{zone-data}

{zone-data:milestones}
* Milestone 1: [DONE] Initial proposal published for review.
* Milestone 2: Working prototype checked into the incubator supporting use cases #1, #2, ...
* Milestone 3: Working prototype checked into the incubator supporting use cases #3 and #4.
* Milestone 4: Unit tests exist, work, and are checked into SVN.
* Milestone 5: Initial documentation exists.
{zone-data}

{zone-data:class-list}
* Zend_Log_Writer_Doctrine
{zone-data}

{zone-data:use-cases}
||UC-01||

*Write a message to the log*

_Generate model class from Yaml schema_

{code}
---
Applog:
columns:
message:
type: string
notnull: true
priority:
type: int(1)
notnull: true
priority_name:
type: string(32)
notnull: true
timestamp:
type: timestamp
notnull: true
{code}

_...Or, create model class manually_

{code}
abstract class BaseApplog extends Doctrine_Record
{
public function setTableDefinition()
{
$this->setTableName('applog');
$this->hasColumn('message', 'string', null, array('type' => 'string', 'notnull' => true));
$this->hasColumn('priority', 'int', 1, array('type' => 'int', 'notnull' => true, 'length' => '1'));
$this->hasColumn('priority_name', 'string', 32, array('type' => 'string', 'notnull' => true, 'length' => '32'));
$this->hasColumn('timestamp', 'timestamp', null, array('type' => 'timestamp', 'notnull' => true));
}
}
{code}

_Instantiate and write a message to the log_

{code}
$columnMap = array(
'message' => 'message',
'priority' => 'priority',
'priority_name' => 'priorityName',
'timestamp' => 'timestamp',
);
$writer = new Zend_Log_Writer_Doctrine('Applog', $columnMap);

$logger = new Zend_Log($writer);
$logger->info('Testing 1, 2, 3..');
{code}
{zone-data}

{zone-data:skeletons}
{code}
class Zend_Log_Writer_Doctrine extends Zend_Log_Writer_Abstract
{
/**
* @var null|array
*/
private $_columnMap = null;

/**
* @var string
*/
private $_modelClass = null;

/**
* Constructor
*
* @param string $modelClass
* @param array $columnMap
* @return void
*/
public function __construct($modelClass, $columnMap = null)
{
}

/**
* Disable formatting
*
* @param mixed $formatter
* @return void
* @throws Zend_Log_Exception
*/
public function setFormatter($formatter)
{
}

/**
* Write a message to the log
*
* @param array $events
* @return void
*/
protected function _write($events)
{
}
}
{code}
{zone-data}

{zone-template-instance}]]></ac:plain-text-body></ac:macro>