[18220] | 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 | * @subpackage appenders |
---|
| 21 | */ |
---|
| 22 | |
---|
| 23 | /** |
---|
| 24 | * @ignore |
---|
| 25 | */ |
---|
| 26 | if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__) . '/..'); |
---|
| 27 | |
---|
| 28 | /** |
---|
| 29 | */ |
---|
| 30 | require_once(LOG4PHP_DIR . '/LoggerAppenderSkeleton.php'); |
---|
| 31 | require_once(LOG4PHP_DIR . '/LoggerLog.php'); |
---|
| 32 | |
---|
| 33 | /** |
---|
| 34 | * LoggerAppenderEcho uses {@link PHP_MANUAL#echo echo} function to output events. |
---|
| 35 | * |
---|
| 36 | * <p>This appender requires a layout.</p> |
---|
| 37 | * |
---|
| 38 | * @author Marco Vassura |
---|
| 39 | * @version $Revision: 635069 $ |
---|
| 40 | * @package log4php |
---|
| 41 | * @subpackage appenders |
---|
| 42 | */ |
---|
| 43 | class LoggerAppenderEcho extends LoggerAppenderSkeleton { |
---|
| 44 | |
---|
| 45 | /** |
---|
| 46 | * @access private |
---|
| 47 | */ |
---|
| 48 | var $requiresLayout = true; |
---|
| 49 | |
---|
| 50 | /** |
---|
| 51 | * @var boolean used internally to mark first append |
---|
| 52 | * @access private |
---|
| 53 | */ |
---|
| 54 | var $firstAppend = true; |
---|
| 55 | |
---|
| 56 | function activateOptions() |
---|
| 57 | { |
---|
| 58 | $this->closed = false; |
---|
| 59 | return; |
---|
| 60 | } |
---|
| 61 | |
---|
| 62 | function close() |
---|
| 63 | { |
---|
| 64 | if (!$this->firstAppend) |
---|
| 65 | echo $this->layout->getFooter(); |
---|
| 66 | $this->closed = true; |
---|
| 67 | } |
---|
| 68 | |
---|
| 69 | function append($event) |
---|
| 70 | { |
---|
| 71 | LoggerLog::debug("LoggerAppenderEcho::append()"); |
---|
| 72 | |
---|
| 73 | if ($this->layout !== null) { |
---|
| 74 | if ($this->firstAppend) { |
---|
| 75 | echo $this->layout->getHeader(); |
---|
| 76 | $this->firstAppend = false; |
---|
| 77 | } |
---|
| 78 | echo $this->layout->format($event); |
---|
| 79 | } |
---|
| 80 | } |
---|
| 81 | } |
---|
| 82 | |
---|