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

Revision 18220, 2.4 KB checked in by yokkuns, 11 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 * @package log4php
19 */
20
21/**
22 * @ignore
23 */
24if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__));
25
26/**
27 * Extend this abstract class to create your own log layout format.
28 * 
29 * @author  Marco Vassura
30 * @version $Revision: 635069 $
31 * @package log4php
32 * @abstract
33 */
34abstract class LoggerLayout {
35
36    /**
37     * Creates LoggerLayout instances with the given class name.
38     *
39     * @param string $class
40     * @return LoggerLayout
41     */
42    public static function factory($class)
43    {
44        if (!empty($class)) {
45            $class = basename($class);
46            if (!class_exists($class))
47                include_once(LOG4PHP_DIR . "/layouts/{$class}.php");
48            if (class_exists($class))
49                return new $class();
50        }
51        return null;
52    }
53
54    /**
55     * Override this method
56     */
57    abstract function activateOptions();
58
59    /**
60     * Override this method to create your own layout format.
61     *
62     * @param LoggerLoggingEvent
63     * @return string
64     */
65    public function format($event)
66    {
67        return $event->getRenderedMessage();
68    }
69   
70    /**
71     * Returns the content type output by this layout.
72     * @return string
73     */
74    public function getContentType()
75    {
76        return "text/plain";
77    }
78           
79    /**
80     * Returns the footer for the layout format.
81     * @return string
82     */
83    public function getFooter()
84    {
85        return null;
86    }
87
88    /**
89     * Returns the header for the layout format.
90     * @return string
91     */
92    public function getHeader()
93    {
94        return null;
95    }
96}
Note: See TracBrowser for help on using the repository browser.