source: branches/comu-ver2/data/module/log4php/php4/log4php/spi/LoggerLocationInfo.php @ 18220

Revision 18220, 3.3 KB checked in by yokkuns, 15 years ago (diff)

#149 ロガークラス作成

RevLine 
[18220]1<?php
2/**
3 * log4php is a PHP port of the log4j java logging package.
4 *
5 * <p>This framework is based on log4j (see {@link http://jakarta.apache.org/log4j log4j} for details).</p>
6 * <p>Design, strategies and part of the methods documentation are developed by log4j team
7 * (Ceki Gülcü as log4j project founder and
8 * {@link http://jakarta.apache.org/log4j/docs/contributors.html contributors}).</p>
9 *
10 * <p>PHP port, extensions and modifications by VxR. All rights reserved.<br>
11 * For more information, please see {@link http://www.vxr.it/log4php/}.</p>
12 *
13 * <p>This software is published under the terms of the LGPL License
14 * a copy of which has been included with this distribution in the LICENSE file.</p>
15 *
16 * @package log4php
17 * @subpackage spi
18 */
19
20/**
21 * @ignore
22 */
23if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__) . '/..');
24
25/**
26 * When location information is not available the constant
27 * <i>NA</i> is returned. Current value of this string
28 * constant is <b>?</b>. 
29 */
30define('LOG4PHP_LOGGER_LOCATION_INFO_NA',  'NA');
31
32/**
33 * The internal representation of caller location information.
34 *
35 * @author VxR <vxr@vxr.it>
36 * @version $Revision: 1.5 $
37 * @package log4php
38 * @subpackage spi
39 * @since 0.3
40 */
41class LoggerLocationInfo {
42
43    /**
44    * @var string Caller's line number.
45    */
46    var $lineNumber = null;
47   
48    /**
49    * @var string Caller's file name.
50    */
51    var $fileName = null;
52   
53    /**
54    * @var string Caller's fully qualified class name.
55    */
56    var $className = null;
57   
58    /**
59    * @var string Caller's method name.
60    */
61    var $methodName = null;
62   
63    /**
64    * @var string
65    */
66    var $fullInfo = null;
67
68    /**
69     * Instantiate location information based on a {@link PHP_MANUAL#debug_backtrace}.
70     *
71     * @param array $trace
72     * @param mixed $caller
73     */
74    function LoggerLocationInfo($trace, $fqcn = null)
75    {
76        $this->lineNumber   = isset($trace['line']) ? $trace['line'] : null;
77        $this->fileName     = isset($trace['file']) ? $trace['file'] : null;
78        $this->className    = isset($trace['class']) ? $trace['class'] : null;
79        $this->methodName   = isset($trace['function']) ? $trace['function'] : null;
80       
81        $this->fullInfo = $this->getClassName() . '.' . $this->getMethodName() .
82                          '(' . $this->getFileName() . ':' . $this->getLineNumber() . ')';
83    }
84
85    function getClassName()
86    {
87        return ($this->className === null) ? LOG4PHP_LOGGER_LOCATION_INFO_NA : $this->className;
88    }
89
90    /**
91     *  Return the file name of the caller.
92     *  <p>This information is not always available.
93     */
94    function getFileName()
95    {
96        return ($this->fileName === null) ? LOG4PHP_LOGGER_LOCATION_INFO_NA : $this->fileName;
97    }
98
99    /**
100     *  Returns the line number of the caller.
101     *  <p>This information is not always available.
102     */
103    function getLineNumber()
104    {
105        return ($this->lineNumber === null) ? LOG4PHP_LOGGER_LOCATION_INFO_NA : $this->lineNumber;
106    }
107
108    /**
109     *  Returns the method name of the caller.
110     */
111    function getMethodName()
112    {
113        return ($this->methodName === null) ? LOG4PHP_LOGGER_LOCATION_INFO_NA : $this->methodName;
114    }
115}
116?>
Note: See TracBrowser for help on using the repository browser.