LoggerAppenderEcho.php
Current file: /home/ihabunek/apache/log4php/src/main/php/appenders/LoggerAppenderEcho.php
Legend: executed not executed dead code

  Coverage
  Classes Functions / Methods Lines
Total
100.00% 1 / 1
100.00% 4 / 4 CRAP
100.00% 22 / 22
LoggerAppenderEcho
100.00% 1 / 1
100.00% 4 / 4 9
100.00% 22 / 22
 close()
100.00% 1 / 1 3
100.00% 7 / 7
 append(LoggerLoggingEvent $event)
100.00% 1 / 1 4
100.00% 12 / 12
 setHtmlLineBreaks($value)
100.00% 1 / 1 1
100.00% 2 / 2
 getHtmlLineBreaks()
100.00% 1 / 1 1
100.00% 1 / 1


       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                 :  * LoggerAppenderEcho uses {@link PHP_MANUAL#echo echo} function to output events.
      23                 :  *                                                                                
      24                 :  * <p>This appender requires a layout.</p>                                        
      25                 :  *                                                                                
      26                 :  * An example php file:                                                           
      27                 :  *                                                                                
      28                 :  * {@example ../../examples/php/appender_echo.php 19}                             
      29                 :  *                                                                                
      30                 :  * An example configuration file:                                                 
      31                 :  *                                                                                
      32                 :  * {@example ../../examples/resources/appender_echo.properties 18}                
      33                 :  *                                                                                
      34                 :  * The above example would print the following:                                   
      35                 :  * <pre>                                                                          
      36                 :  *    Tue Sep  8 22:44:55 2009,812 [6783] DEBUG appender_echo - Hello World!      
      37                 :  * </pre>                                                                         
      38                 :  *                                                                                
      39                 :  * @version $Revision: 1213283 $                                                  
      40                 :  * @package log4php                                                               
      41                 :  * @subpackage appenders                                                          
      42                 :  */                                                                               
      43                 : class LoggerAppenderEcho extends LoggerAppender {                                 
      44                 :     /** boolean used internally to mark first append */                           
      45                 :     protected $firstAppend = true;                                                
      46                 :                                                                                   
      47                 :     /**                                                                           
      48                 :      * If set to true, a <br /> element will be inserted before each line         
      49                 :      * break in the logged message. Default value is false. @var boolean          
      50                 :      */                                                                           
      51                 :     protected $htmlLineBreaks = false;                                            
      52                 :                                                                                   
      53                 :     public function close() {                                                     
      54              24 :         if($this->closed != true) {                                               
      55              24 :             if(!$this->firstAppend) {                                             
      56               8 :                 echo $this->layout->getFooter();                                  
      57               8 :             }                                                                     
      58              24 :         }                                                                         
      59              24 :         $this->closed = true;                                                     
      60              24 :     }                                                                             
      61                 :                                                                                   
      62                 :     public function append(LoggerLoggingEvent $event) {                           
      63              12 :         if($this->layout !== null) {                                              
      64              12 :             if($this->firstAppend) {                                              
      65              12 :                 echo $this->layout->getHeader();                                  
      66              12 :                 $this->firstAppend = false;                                       
      67              12 :             }                                                                     
      68              12 :             $text = $this->layout->format($event);                                
      69                 :                                                                                   
      70              12 :             if ($this->htmlLineBreaks) {                                          
      71               2 :                 $text = nl2br($text);                                             
      72               2 :             }                                                                     
      73              12 :             echo $text;                                                           
      74              12 :         }                                                                         
      75              12 :     }                                                                             
      76                 :                                                                                   
      77                 :     public function setHtmlLineBreaks($value) {                                   
      78               3 :         $this->setBoolean('htmlLineBreaks', $value);                              
      79               3 :     }                                                                             
      80                 :                                                                                   
      81                 :     public function getHtmlLineBreaks() {                                         
      82               2 :         return $this->htmlLineBreaks;                                             
      83                 :     }                                                                             
      84                 : }                                                                                 
      85                 :                                                                                   

Generated by PHP_CodeCoverage 1.1.1 using PHP 5.3.3-7+squeeze3 and PHPUnit 3.6.3 at Sat Feb 18 22:32:39 GMT 2012.