Example #1
0
 /**
  * Factory to construct the logger and one or more writers
  * based on the configuration array
  *
  * @param  array|Zend_Config Array or instance of Zend_Config
  * @return AM_Log
  * @throws Zend_Log_Exception
  */
 public static function factory($aConfig = array())
 {
     if ($aConfig instanceof Zend_Config) {
         $aConfig = $aConfig->toArray();
     }
     if (!is_array($aConfig) || empty($aConfig)) {
         /** @see Zend_Log_Exception */
         require_once 'Zend/Log/Exception.php';
         throw new Zend_Log_Exception('Configuration must be an array or instance of Zend_Config');
     }
     $oLog = new self();
     if (array_key_exists('timestampFormat', $aConfig)) {
         if (null != $aConfig['timestampFormat'] && '' != $aConfig['timestampFormat']) {
             $oLog->setTimestampFormat($aConfig['timestampFormat']);
         }
         unset($aConfig['timestampFormat']);
     }
     if (!is_array(current($aConfig))) {
         $oLog->addWriter(current($aConfig));
     } else {
         foreach ($aConfig as $writer) {
             $oLog->addWriter($writer);
         }
     }
     return $oLog;
 }
Example #2
0
 /**
  * Factory to construct the logger and one or more writers
  * based on the configuration array
  *
  * @throws  Zend_Log_Exception
  * @param   Enlight_Config|array $config
  * @return  Enlight_Components_Log
  */
 public static function factory($config = array())
 {
     if ($config instanceof Zend_Config) {
         $config = $config->toArray();
     }
     if (!is_array($config) || empty($config)) {
         throw new Enlight_Exception('Configuration must be an array or instance of Enlight_Config');
     }
     $log = new self();
     if (array_key_exists('timestampFormat', $config)) {
         if (null != $config['timestampFormat'] && '' != $config['timestampFormat']) {
             $log->setTimestampFormat($config['timestampFormat']);
         }
         unset($config['timestampFormat']);
     }
     if (!is_array(current($config))) {
         $log->addWriter(current($config));
     } else {
         foreach ($config as $writer) {
             $log->addWriter($writer);
         }
     }
     return $log;
 }