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
 /**
  * @param string $component
  * @return ApplicationLogger
  */
 public static function getInstance($component = "default", $initDbHandler = false)
 {
     if (array_key_exists($component, self::$instances)) {
         return self::$instances[$component];
     }
     $logger = new self();
     $logger->setComponent($component);
     if ($initDbHandler) {
         $logger->addWriter(new \Pimcore\Log\Handler\ApplicationLoggerDb());
     }
     self::$instances[$component] = $logger;
     return $logger;
 }
Example #3
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;
 }
Example #4
0
 /**
  * Copy from Zend\Log\Logger else it can't be extended
  * Factory to construct the logger and one or more writers
  * based on the configuration array
  *
  * @param  array|Config Array or instance of Zend\Config\Config
  * @return Logger
  * @throws ExceptionInterface
  */
 public static function factory($config = array())
 {
     if ($config instanceof Config) {
         $config = $config->toArray();
     }
     $log = new self();
     if (empty($config)) {
         return $log;
     }
     if (!is_array($config)) {
         $config = [$config];
     }
     foreach ($config as $writer) {
         $log->addWriter($writer);
     }
     return $log;
 }
Example #5
0
 public static function easyFactory($filename = '', $verbose = false, $level = 7)
 {
     $result = new self();
     if ($filename) {
         $result->addWriter(new Miao_Log_Writer_Stream($filename));
     }
     if ($verbose) {
         $result->addWriter(new Miao_Log_Writer_Stream('php://output'));
     }
     if (!$filename && !$verbose) {
         $result->addWriter(new Miao_Log_Writer_Null());
     }
     $filter = new Miao_Log_Filter_Priority($level);
     $result->addFilter($filter);
     return $result;
 }
Example #6
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 Zend_Log
  */
 public static function factory($config = array())
 {
     if ($config instanceof Zend_Config) {
         $config = $config->toArray();
     }
     if (!is_array($config) || empty($config)) {
         /** @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');
     }
     $log = new self();
     if (!is_array(current($config))) {
         $log->addWriter(current($config));
     } else {
         foreach ($config as $writer) {
             $log->addWriter($writer);
         }
     }
     return $log;
 }
Example #7
0
 /**
  * Factory to construct the logger and one or more writers
  * based on the configuration array
  *
  * @param  array|\Zend\Config\Config Array or instance of \Zend\Config\Config
  * @throws \Zend\Log\Exception\InvalidArgumentException
  * @return \Zend\Log\Logger
  */
 public static function factory($config = array())
 {
     if ($config instanceof Config) {
         $config = $config->toArray();
     }
     if (!is_array($config) || empty($config)) {
         throw new Exception\InvalidArgumentException('Configuration must be an array or instance of Zend\\Config\\Config');
     }
     $log = new self();
     if (!is_array(current($config))) {
         $log->addWriter(current($config));
     } else {
         foreach ($config as $writer) {
             $log->addWriter($writer);
         }
     }
     return $log;
 }