diff options
Diffstat (limited to 'libs/Zend/Log/Writer/Db.php')
-rw-r--r-- | libs/Zend/Log/Writer/Db.php | 42 |
1 files changed, 34 insertions, 8 deletions
diff --git a/libs/Zend/Log/Writer/Db.php b/libs/Zend/Log/Writer/Db.php index 2130efe28e..6f77a12cb7 100644 --- a/libs/Zend/Log/Writer/Db.php +++ b/libs/Zend/Log/Writer/Db.php @@ -15,21 +15,21 @@ * @category Zend * @package Zend_Log * @subpackage Writer - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Db.php 16219 2009-06-21 19:45:39Z thomas $ + * @version $Id: Db.php 20096 2010-01-06 02:05:09Z bkarwin $ */ /** Zend_Log_Writer_Abstract */ -require_once 'Zend/Log/Writer/Abstract.php'; +// require_once 'Zend/Log/Writer/Abstract.php'; /** * @category Zend * @package Zend_Log * @subpackage Writer - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Db.php 16219 2009-06-21 19:45:39Z thomas $ + * @version $Id: Db.php 20096 2010-01-06 02:05:09Z bkarwin $ */ class Zend_Log_Writer_Db extends Zend_Log_Writer_Abstract { @@ -67,11 +67,38 @@ class Zend_Log_Writer_Db extends Zend_Log_Writer_Abstract } /** + * Create a new instance of Zend_Log_Writer_Db + * + * @param array|Zend_Config $config + * @return Zend_Log_Writer_Db + * @throws Zend_Log_Exception + */ + static public function factory($config) + { + $config = self::_parseConfig($config); + $config = array_merge(array( + 'db' => null, + 'table' => null, + 'columnMap' => null, + ), $config); + + if (isset($config['columnmap'])) { + $config['columnMap'] = $config['columnmap']; + } + + return new self( + $config['db'], + $config['table'], + $config['columnMap'] + ); + } + + /** * Formatting is not possible on this writer */ public function setFormatter($formatter) { - require_once 'Zend/Log/Exception.php'; + // require_once 'Zend/Log/Exception.php'; throw new Zend_Log_Exception(get_class() . ' does not support formatting'); } @@ -94,7 +121,7 @@ class Zend_Log_Writer_Db extends Zend_Log_Writer_Abstract protected function _write($event) { if ($this->_db === null) { - require_once 'Zend/Log/Exception.php'; + // require_once 'Zend/Log/Exception.php'; throw new Zend_Log_Exception('Database adapter is null'); } @@ -109,5 +136,4 @@ class Zend_Log_Writer_Db extends Zend_Log_Writer_Abstract $this->_db->insert($this->_table, $dataToInsert); } - } |