web/lib/Zend/Log.php
changeset 1230 68c69c656a2c
parent 807 877f952ae2bd
equal deleted inserted replaced
1229:5a6b6e770365 1230:68c69c656a2c
    12  * obtain it through the world-wide-web, please send an email
    12  * obtain it through the world-wide-web, please send an email
    13  * to license@zend.com so we can send you a copy immediately.
    13  * to license@zend.com so we can send you a copy immediately.
    14  *
    14  *
    15  * @category   Zend
    15  * @category   Zend
    16  * @package    Zend_Log
    16  * @package    Zend_Log
    17  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    17  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
    18  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    18  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    19  * @version    $Id: Log.php 25131 2012-11-16 15:29:18Z rob $
    19  * @version    $Id$
    20  */
    20  */
    21 
    21 
    22 /**
    22 /**
    23  * @category   Zend
    23  * @category   Zend
    24  * @package    Zend_Log
    24  * @package    Zend_Log
    25  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    25  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
    26  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    26  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    27  * @version    $Id: Log.php 25131 2012-11-16 15:29:18Z rob $
    27  * @version    $Id$
    28  */
    28  */
    29 class Zend_Log
    29 class Zend_Log
    30 {
    30 {
    31     const EMERG   = 0;  // Emergency: system is unusable
    31     const EMERG   = 0;  // Emergency: system is unusable
    32     const ALERT   = 1;  // Alert: action must be taken immediately
    32     const ALERT   = 1;  // Alert: action must be taken immediately
   134             /** @see Zend_Log_Exception */
   134             /** @see Zend_Log_Exception */
   135             require_once 'Zend/Log/Exception.php';
   135             require_once 'Zend/Log/Exception.php';
   136             throw new Zend_Log_Exception('Configuration must be an array or instance of Zend_Config');
   136             throw new Zend_Log_Exception('Configuration must be an array or instance of Zend_Config');
   137         }
   137         }
   138 
   138 
   139         $log = new self;
   139         if (array_key_exists('className', $config)) {
       
   140             $class = $config['className'];
       
   141             unset($config['className']);
       
   142         } else {
       
   143             $class = __CLASS__;
       
   144         }
       
   145 
       
   146         $log = new $class;
       
   147 
       
   148         if (!$log instanceof Zend_Log) {
       
   149             /** @see Zend_Log_Exception */
       
   150             require_once 'Zend/Log/Exception.php';
       
   151             throw new Zend_Log_Exception('Passed className does not belong to a descendant of Zend_Log');
       
   152         }
   140 
   153 
   141         if (array_key_exists('timestampFormat', $config)) {
   154         if (array_key_exists('timestampFormat', $config)) {
   142             if (null != $config['timestampFormat'] && '' != $config['timestampFormat']) {
   155             if (null != $config['timestampFormat'] && '' != $config['timestampFormat']) {
   143                 $log->setTimestampFormat($config['timestampFormat']);
   156                 $log->setTimestampFormat($config['timestampFormat']);
   144             }
   157             }
   302         // PHP >= 5.3.0 namespace given?
   315         // PHP >= 5.3.0 namespace given?
   303         if (substr($namespace, -1) == '\\') {
   316         if (substr($namespace, -1) == '\\') {
   304             return $namespace . $className;
   317             return $namespace . $className;
   305         }
   318         }
   306 
   319 
   307         // emtpy namespace given?
   320         // empty namespace given?
   308         if (strlen($namespace) === 0) {
   321         if (strlen($namespace) === 0) {
   309             return $className;
   322             return $className;
   310         }
   323         }
   311 
   324 
   312         return $namespace . '_' . $className;
   325         return $namespace . '_' . $className;