source: branches/comu-ver2/data/module/log4php/php5/log4php/LoggerRoot.php @ 18220

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

#149 ロガークラス作成

Line 
1<?php
2/**
3 * Licensed to the Apache Software Foundation (ASF) under one or more
4 * contributor license agreements.  See the NOTICE file distributed with
5 * this work for additional information regarding copyright ownership.
6 * The ASF licenses this file to You under the Apache License, Version 2.0
7 * (the "License"); you may not use this file except in compliance with
8 * the License.  You may obtain a copy of the License at
9 *
10 *     http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 *
19 * @package log4php
20 */
21
22/**
23 * @ignore
24 */
25if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__));
26 
27/**
28 */
29require_once(LOG4PHP_DIR . '/Logger.php');
30require_once(LOG4PHP_DIR . '/LoggerLevel.php');
31
32/**
33 * The root logger.
34 *
35 * @author  Marco Vassura
36 * @version $Revision: 635069 $
37 * @package log4php
38 * @see Logger
39 */
40class LoggerRoot extends Logger {
41
42    /**
43     * @var string name of logger
44     */
45    protected $name   = 'root';
46
47    /**
48     * @var object must be null for LoggerRoot
49     */
50    protected $parent = null;
51   
52
53    /**
54     * Constructor
55     *
56     * @param integer $level initial log level
57     */
58    public function __construct($level = null)
59    {
60        parent::__construct($this->name);
61        if ($level == null)
62            $level = LoggerLevel::getLevelAll();
63        $this->setLevel($level);
64    }
65   
66    /**
67     * @return LoggerLevel the level
68     */
69    public function getChainedLevel()
70    {
71        return $this->level;
72    }
73   
74    /**
75     * Setting a null value to the level of the root category may have catastrophic results.
76     * @param LoggerLevel $level
77     */
78    public function setLevel($level)
79    {
80        if ($level != null) {
81        $this->level = $level;
82    }   
83    }   
84 
85    /**
86     * Please use setLevel() instead.
87     * @param LoggerLevel $level
88     * @deprecated
89     */
90    public function setPriority($level)
91    {
92        $this->setLevel($level);
93    }
94   
95    /**
96     * Always returns false.
97     * Because LoggerRoot has no parents, it returns false.
98     * @param Logger $parent
99     * @return boolean
100     */
101    public function setParent($parent)
102    {
103        return false;
104    } 
105}
Note: See TracBrowser for help on using the repository browser.