[ Index ] |
|
Code source de Symfony 1.0.0 |
1 <?php 2 /* 3 * $Id: MojaviLogAdapter.php 64 2005-05-13 02:43:56Z root $ 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://propel.phpdb.org>. 20 */ 21 22 // include BasicLogger from include path 23 require_once('propel/logger/BasicLogger.php'); 24 25 /** 26 * Mojavi logging adapter for propel 27 * 28 * @author Brandon Keepers <brandon@opensoul.org> 29 * @version $Revision: 64 $ 30 * @package propel.logger 31 */ 32 class MojaviLogAdapter implements BasicLogger { 33 34 /** 35 * Instance of mojavi logger 36 */ 37 private $logger = null; 38 39 /** 40 * constructor for setting up Mojavi log adapter 41 * 42 * @param ErrorLog $logger instance of Mojavi error log obtained by 43 * calling LogManager::getLogger(); 44 */ 45 public function __construct($logger = null) 46 { 47 $this->logger = $logger; 48 } 49 50 /** 51 * A convenience function for logging an alert event. 52 * 53 * @param mixed $message String or Exception object containing the message 54 * to log. 55 */ 56 public function alert($message) 57 { 58 $this->log($message, 'alert'); 59 } 60 61 /** 62 * A convenience function for logging a critical event. 63 * 64 * @param mixed $message String or Exception object containing the message 65 * to log. 66 */ 67 public function crit($message) 68 { 69 $this->log($message, 'crit'); 70 } 71 72 /** 73 * A convenience function for logging an error event. 74 * 75 * @param mixed $message String or Exception object containing the message 76 * to log. 77 */ 78 public function err($message) 79 { 80 $this->log($message, 'err'); 81 } 82 83 /** 84 * A convenience function for logging a warning event. 85 * 86 * @param mixed $message String or Exception object containing the message 87 * to log. 88 */ 89 public function warning($message) 90 { 91 $this->log($message, 'warning'); 92 } 93 94 95 /** 96 * A convenience function for logging an critical event. 97 * 98 * @param mixed $message String or Exception object containing the message 99 * to log. 100 */ 101 public function notice($message) 102 { 103 $this->log($message, 'notice'); 104 } 105 /** 106 * A convenience function for logging an critical event. 107 * 108 * @param mixed $message String or Exception object containing the message 109 * to log. 110 */ 111 public function info($message) 112 { 113 $this->log($message, 'info'); 114 } 115 116 /** 117 * A convenience function for logging a debug event. 118 * 119 * @param mixed $message String or Exception object containing the message 120 * to log. 121 */ 122 public function debug($message) 123 { 124 $this->log($message, 'debug'); 125 } 126 127 /** 128 * Primary method to handle logging. 129 * 130 * @param mixed $message String or Exception object containing the message 131 * to log. 132 * @param int $severity The numeric severity. Defaults to null so that no 133 * assumptions are made about the logging backend. 134 */ 135 public function log($message, $severity = null) 136 { 137 if(is_null($this->logger)) 138 $this->logger = LogManager::getLogger('propel'); 139 140 switch($severity) 141 { 142 case 'crit': 143 $method = 'fatal'; 144 break; 145 case 'err': 146 $method = 'error'; 147 break; 148 case 'alert': 149 case 'warning': 150 $method = 'warning'; 151 break; 152 case 'notice': 153 case 'info': 154 $method = 'info'; 155 break; 156 case 'debug': 157 default: 158 $method = 'debug'; 159 } 160 161 // get a backtrace to pass class, function, file, & line to Mojavi logger 162 $trace = debug_backtrace(); 163 164 // call the appropriate Mojavi logger method 165 $this->logger->{$method} ( 166 $message, 167 $trace[2]['class'], 168 $trace[2]['function'], 169 $trace[1]['file'], 170 $trace[1]['line'] 171 ); 172 } 173 } 174 175 176
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 |