[ Index ] |
|
Code source de Symfony 1.0.0 |
1 <?php 2 /* 3 * $Id: EchoTask.php 3076 2006-12-18 08:52:12Z fabien $ 4 * 5 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 6 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 7 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 8 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 9 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 10 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 11 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 12 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 13 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 14 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 15 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 16 * 17 * This software consists of voluntary contributions made by many individuals 18 * and is licensed under the LGPL. For more information please see 19 * <http://phing.info>. 20 */ 21 22 include_once 'phing/Task.php'; 23 24 /** 25 * Echos a message to the logging system or to a file 26 * 27 * @author Michiel Rook <michiel.rook@gmail.com> 28 * @author Andreas Aderhold, andi@binarycloud.com 29 * @version $Revision: 1.5 $ $Date: 2006-07-07 20:15:35 +0200 (Fri, 07 Jul 2006) $ 30 * @package phing.tasks.system 31 */ 32 33 class EchoTask extends Task { 34 35 protected $msg = ""; 36 37 protected $file = ""; 38 39 protected $append = false; 40 41 protected $level = "info"; 42 43 function main() { 44 switch ($this->level) 45 { 46 case "error": $loglevel = PROJECT_MSG_ERR; break; 47 case "warning": $loglevel = PROJECT_MSG_WARN; break; 48 case "info": $loglevel = PROJECT_MSG_INFO; break; 49 case "verbose": $loglevel = PROJECT_MSG_VERBOSE; break; 50 case "debug": $loglevel = PROJECT_MSG_DEBUG; break; 51 } 52 53 if (empty($this->file)) 54 { 55 $this->log($this->msg, $loglevel); 56 } 57 else 58 { 59 if ($this->append) 60 { 61 $handle = fopen($this->file, "a"); 62 } 63 else 64 { 65 $handle = fopen($this->file, "w"); 66 } 67 68 fwrite($handle, $this->msg); 69 70 fclose($handle); 71 } 72 } 73 74 /** setter for file */ 75 function setFile($file) 76 { 77 $this->file = (string) $file; 78 } 79 80 /** setter for level */ 81 function setLevel($level) 82 { 83 $this->level = (string) $level; 84 } 85 86 /** setter for append */ 87 function setAppend($append) 88 { 89 $this->append = $append; 90 } 91 92 /** setter for message */ 93 function setMsg($msg) { 94 $this->setMessage($msg); 95 } 96 97 /** alias setter */ 98 function setMessage($msg) { 99 $this->msg = (string) $msg; 100 } 101 102 /** Supporting the <echo>Message</echo> syntax. */ 103 function addText($msg) 104 { 105 $this->msg = (string) $msg; 106 } 107 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Fri Mar 16 22:42:14 2007 | par Balluche grâce à PHPXref 0.7 |