| [ Index ] |
|
Code source de eGroupWare 1.2.106-2 |
1 <?php 2 /**************************************************************************\ 3 * eGroupWare - log * 4 * http://www.egroupware.org * 5 * This application written by jerry westrick <jerry@westrick.com> * 6 * -------------------------------------------- * 7 * This program is free software; you can redistribute it and/or modify it * 8 * under the terms of the GNU General Public License as published by the * 9 * Free Software Foundation; either version 2 of the License, or (at your * 10 * option) any later version. * 11 \**************************************************************************/ 12 13 /* $Id: class.log.inc.php 20295 2006-02-15 12:31:25Z $ */ 14 15 class log 16 { 17 /***************************\ 18 * Instance Variables... * 19 \***************************/ 20 var $errorstack = array(); 21 var $public_functions = array( 22 'message', 23 'error', 24 'iserror', 25 'severity', 26 'commit', 27 'clearstack', 28 'astable' 29 ); 30 var $log_table = 'egw_log'; 31 var $msg_table = 'egw_log_msg'; 32 33 function message($etext,$p0='',$p1='',$p2='',$p3='',$p4='',$p5='',$p6='',$p7='',$p8='',$p9='') 34 { 35 $parms = array($p0,$p1,$p2,$p3,$p4,$p5,$p6,$p7,$p8,$p9); 36 CreateObject('phpgwapi.error',$etext,$parms,1); 37 } 38 39 function error($etext,$p0='',$p1='',$p2='',$p3='',$p4='',$p5='',$p6='',$p7='',$p8='',$p9='') 40 { 41 $parms = array($p0,$p1,$p2,$p3,$p4,$p5,$p6,$p7,$p8,$p9); 42 CreateObject('phpgwapi.error',$etext,$parms,false); 43 } 44 45 function iserror($ecode) 46 { 47 $errorstack = $this->errorstack; 48 reset($errorstack); 49 while(list(,$err)=each($errorstack)) 50 { 51 if ($ecode == $err->code) 52 { 53 return true; 54 } 55 } 56 return false; 57 } 58 59 function severity() 60 { 61 $max = 'I'; 62 $errorstack = $this->errorstack; 63 reset($errorstack); 64 while(list(,$err)=each($errorstack)) 65 { 66 switch($err->severity) 67 { 68 case 'F': 69 return 'F'; 70 break; 71 case 'E': 72 $max = 'E'; 73 break; 74 case 'W': 75 if ($max == 'I') 76 { 77 $max = 'W'; 78 } 79 break; 80 } 81 } 82 return $max; 83 } 84 85 function commit() 86 { 87 $db = clone($GLOBALS['egw']->db); 88 $db->query("insert into $this->log_table (log_date, log_user, log_app, log_severity) values " 89 ."('". $GLOBALS['egw']->db->to_timestamp(time()) 90 ."','".$GLOBALS['egw']->session->account_id 91 ."','".$GLOBALS['egw_info']['flags']['currentapp']."'" 92 .",'".$this->severity()."'" 93 .")" 94 ,__LINE__,__FILE__); 95 96 $errorstack = $this->errorstack; 97 for ($i = 0; $i < count($errorstack); $i++) 98 { 99 $err = $errorstack[$i]; 100 $db->query("insert into $this->msg_table " 101 . "(log_msg_seq_no, log_msg_date, " 102 . "log_msg_severity, log_msg_code, log_msg_msg, log_msg_parms) values " 103 . "(" . $i 104 . ", '" . $GLOBALS['egw']->db->to_timestamp($err->timestamp) 105 . "', '". $err->severity . "'" 106 . ", '". $err->code . "'" 107 . ", '". $err->msg . "'" 108 . ", '". addslashes(implode('|',$err->parms)). "'" 109 . ")",__LINE__,__FILE__); 110 } 111 unset ($errorstack); 112 unset ($this->errorstack); 113 $this->errorstack = array(); 114 } 115 116 function clearstack() 117 { 118 $new = array(); 119 reset($this->errorstack); 120 for ($i = 0; $i < count($this->errorstack); $i++) 121 { 122 $err = $this->errorstack[$i]; 123 if ($err->ismsg) 124 { 125 $new[] = $err; 126 } 127 } 128 unset ($this->errorstack); 129 $this->errorstack = $new; 130 } 131 132 function astable() 133 { 134 $html = "<center>\n"; 135 $html .= "<table width=\"98%\">\n"; 136 $html .= "\t<tr bgcolor=\"D3DCFF\">\n"; 137 $html .= "\t\t<td width=\"2%\">No</td>\n"; 138 $html .= "\t\t<td width=\"16%\">Date</td>\n"; 139 $html .= "\t\t<td width=\"15%\">App</td>\n"; 140 $html .= "\t\t<td align=\"center\", width=\"2%\">S</td>\n"; 141 $html .= "\t\t<td width=\"10%\">Error Code</td>\n"; 142 $html .= "\t\t<td >Msg</td>\n"; 143 $html .= "\t</tr>\n"; 144 145 $errorstack = $this->errorstack; 146 for ($i = 0; $i < count($errorstack); $i++) 147 { 148 $err = $errorstack[$i]; 149 switch ($err->severity) 150 { 151 case 'I': 152 $color = 'C0FFC0'; 153 break; 154 case 'W': 155 $color = 'FFFFC0'; 156 break; 157 case 'E': 158 $color = 'FFC0C0'; 159 break; 160 case 'F': 161 $color = 'FF0909'; 162 break; 163 } 164 165 $html .= "\t<tr bgcolor=".'"'.$color.'"'.">\n"; 166 $html .= "\t\t<td align=center>".$i."</td>\n"; 167 $html .= "\t\t<td>".$GLOBALS['egw']->common->show_date($err->timestamp)."</td>\n"; 168 $html .= "\t\t<td>".$GLOBALS['egw_info']['flags']['currentapp']."  </td>\n"; 169 $html .= "\t\t<td align=center>".$err->severity."</td>\n"; 170 $html .= "\t\t<td>".$err->code."</td>\n"; 171 $html .= "\t\t<td>".$err->langmsg()."</td>\n"; 172 $html .= "\t</tr>\n"; 173 } 174 $html .= "</table>\n"; 175 $html .= "</center>\n"; 176 177 return $html; 178 } 179 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Sun Feb 25 17:20:01 2007 | par Balluche grâce à PHPXref 0.7 |