PageRenderTime 24ms CodeModel.GetById 21ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/Application/Resource/Log.php

https://bitbucket.org/bigstylee/zend-framework
PHP | 83 lines | 25 code | 6 blank | 52 comment | 1 complexity | b1cbbe6639bb83f25c8496a701e675c5 MD5 | raw file
 1<?php
 2/**
 3 * Zend Framework
 4 *
 5 * LICENSE
 6 *
 7 * This source file is subject to the new BSD license that is bundled
 8 * with this package in the file LICENSE.txt.
 9 * It is also available through the world-wide-web at this URL:
10 * http://framework.zend.com/license/new-bsd
11 * If you did not receive a copy of the license and are unable to
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.
14 *
15 * @category   Zend
16 * @package    Zend_Application
17 * @subpackage Resource
18 * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
19 * @license    http://framework.zend.com/license/new-bsd     New BSD License
20 * @version    $Id: Log.php 24607 2012-01-16 16:45:49Z xerkus $
21 */
22
23/**
24 * @see Zend_Application_Resource_ResourceAbstract
25 */
26require_once 'Zend/Application/Resource/ResourceAbstract.php';
27
28
29/**
30 * Resource for initializing logger
31 *
32 * @uses       Zend_Application_Resource_ResourceAbstract
33 * @category   Zend
34 * @package    Zend_Application
35 * @subpackage Resource
36 * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
37 * @license    http://framework.zend.com/license/new-bsd     New BSD License
38 */
39class Zend_Application_Resource_Log
40    extends Zend_Application_Resource_ResourceAbstract
41{
42    /**
43     * @var Zend_Log
44     */
45    protected $_log;
46
47    /**
48     * Defined by Zend_Application_Resource_Resource
49     *
50     * @return Zend_Log
51     */
52    public function init()
53    {
54        return $this->getLog();
55    }
56
57    /**
58     * Attach logger
59     *
60     * @param  Zend_Log $log
61     * @return Zend_Application_Resource_Log
62     */
63    public function setLog(Zend_Log $log)
64    {
65        $this->_log = $log;
66        return $this;
67    }
68
69    /**
70     * Retrieve logger object
71     *
72     * @return Zend_Log
73     */
74    public function getLog()
75    {
76        if (null === $this->_log) {
77            $options = $this->getOptions();
78            $log = Zend_Log::factory($options);
79            $this->setLog($log);
80        }
81        return $this->_log;
82    }
83}