diff --git a/admin/inc/class.uilog.inc.php b/admin/inc/class.uilog.inc.php index 55af64d017..527b6084b1 100644 --- a/admin/inc/class.uilog.inc.php +++ b/admin/inc/class.uilog.inc.php @@ -39,6 +39,7 @@ + // Handle the Edit Table Button if (isset($editable)) { @@ -114,8 +115,11 @@ 'log_msg_date_e', 'log_msg_severity', 'log_msg_code', - 'log_msg_text' + 'log_msg_text', + 'log_msg_file', + 'log_msg_line' ); + // Store defaults in session data... $phpgw->session->appsession ('session_data', 'log', @@ -138,17 +142,51 @@ function list_log() { global $phpgw, $phpgw_info; -/* -$phpgw->log->write(array('text'=>'I-TestWrite, write: %1','p1'=>'This message should appear in log')); -$phpgw->log->message(array('text'=>'I-TestMsg, msg: %1','p1'=>'This message should appear in log')); -$phpgw->log->error(array('text'=>'I-TestInfo, info: %1','p1'=>'This Informational should not be in log')); -$phpgw->log->clearstack(); -$phpgw->log->error(array('text'=>'I-TestInfo, info: %1','p1'=>'This Informational should be in log')); -$phpgw->log->error(array('text'=>'W-TestWarn, warn: %1','p1'=>'This is a test Warning')); -$phpgw->log->error(array('text'=>'E-TestError, err: %1','p1'=>'This is a test Error')); -$phpgw->log->error(array('text'=>'F-Abend, abort: %1','p1'=>'Force abnormal termination')); -$phpgw->log->commit(); // commit error stack to log... -*/ + + if (false) // add some errors to the log... + { + // Test 1: single Error line immedeately to errorlog + // (could be type Debug, Info, Warning, or Error) + $phpgw->log->write(array('text'=>'I-TestWrite, write: %1','p1'=>'This message should appear in log','file'=>__FILE__,'line'=>__LINE__)); + + + // Test 2: A message should appear in log even if clearstack is called + $phpgw->log->message(array('text'=>'I-TestMsg, msg: %1','p1'=>'This message should appear in log','file'=>__FILE__,'line'=>__LINE__)); + $phpgw->log->error(array('text'=>'I-TestInfo, info: %1','p1'=>'This Informational should not be in log','file'=>__FILE__,'line'=>__LINE__)); + $phpgw->log->clearstack(); + $phpgw->log->commit(); // commit error stack to log... + + // Test 3: one debug message + $phpgw->log->error(array('text'=>'D-Debug, dbg: %1','p1'=>'This debug statment should be in log','file'=>__FILE__,'line'=>__LINE__)); + $phpgw->log->commit(); // commit error stack to log... + + // Test 3: debug and one informational + $phpgw->log->error(array('text'=>'D-Debug, dbg: %1','p1'=>'This debug statment should be in log','file'=>__FILE__,'line'=>__LINE__)); + $phpgw->log->error(array('text'=>'I-TestInfo, info: %1','p1'=>'This Informational should be in log','file'=>__FILE__,'line'=>__LINE__)); + $phpgw->log->commit(); // commit error stack to log... + + // Test 4: an informational and a Warning + $phpgw->log->error(array('text'=>'D-Debug, dbg: %1','p1'=>'This debug statment should be in log','file'=>__FILE__,'line'=>__LINE__)); + $phpgw->log->error(array('text'=>'I-TestInfo, info: %1','p1'=>'This Informational should be in log','file'=>__FILE__,'line'=>__LINE__)); + $phpgw->log->error(array('text'=>'W-TestWarn, warn: %1','p1'=>'This is a test Warning','file'=>__FILE__,'line'=>__LINE__)); + $phpgw->log->commit(); // commit error stack to log... + + // Test 5: and an error + $phpgw->log->error(array('text'=>'D-Debug, dbg: %1','p1'=>'This debug statment should be in log','file'=>__FILE__,'line'=>__LINE__)); + $phpgw->log->error(array('text'=>'I-TestInfo, info: %1','p1'=>'This Informational should be in log','file'=>__FILE__,'line'=>__LINE__)); + $phpgw->log->error(array('text'=>'W-TestWarn, warn: %1','p1'=>'This is a test Warning','file'=>__FILE__,'line'=>__LINE__)); + $phpgw->log->error(array('text'=>'E-TestError, err: %1','p1'=>'This is a test Error','file'=>__FILE__,'line'=>__LINE__)); + $phpgw->log->commit(); // commit error stack to log... + + + // Test 6: and finally a fatal... + $phpgw->log->error(array('text'=>'D-Debug, dbg: %1','p1'=>'This debug statment should be in log','file'=>__FILE__,'line'=>__LINE__)); + $phpgw->log->error(array('text'=>'I-TestInfo, info: %1','p1'=>'This Informational should be in log','file'=>__FILE__,'line'=>__LINE__)); + $phpgw->log->error(array('text'=>'W-TestWarn, warn: %1','p1'=>'This is a test Warning','file'=>__FILE__,'line'=>__LINE__)); + $phpgw->log->error(array('text'=>'E-TestError, err: %1','p1'=>'This is a test Error','file'=>__FILE__,'line'=>__LINE__)); + $phpgw->log->error(array('text'=>'F-Abend, abort: %1','p1'=>'Force abnormal termination','file'=>__FILE__,'line'=>__LINE__)); + + }; $this->t->set_file(array('log_list_t' => 'log.tpl')); /* // --------------------------------- nextmatch --------------------------- @@ -227,6 +265,7 @@ $phpgw->log->commit(); // commit error stack to log... switch($row[$this->column['log_severity']]['value']) { + case 'D': $row[$this->column['log_severity']]['bgcolor'] = 'D3DCFF'; break; case 'I': $row[$this->column['log_severity']]['bgcolor'] = 'C0FFC0'; break; case 'W': $row[$this->column['log_severity']]['bgcolor'] = 'FFFFC0'; break; case 'E': $row[$this->column['log_severity']]['bgcolor'] = 'FFC0C0'; break; @@ -235,6 +274,7 @@ $phpgw->log->commit(); // commit error stack to log... switch($row[$this->column['log_msg_severity']]['value']) { + case 'D': $color = 'D3DCFF'; break; case 'I': $color = 'C0FFC0'; break; case 'W': $color = 'FFFFC0'; break; case 'E': $color = 'FFC0C0'; break; diff --git a/phpgwapi/inc/class.error.inc.php b/phpgwapi/inc/class.error.inc.php index e7596c7e5b..48478afec6 100755 --- a/phpgwapi/inc/class.error.inc.php +++ b/phpgwapi/inc/class.error.inc.php @@ -23,24 +23,30 @@ var $parms = array(); var $ismsg = 0; var $timestamp; + var $fname; + var $line; + var $app; var $public_functions = array(); - /*******************************************\ - * Constructor * - * to be accessed as new error() * - \*******************************************/ // Translate Message into Language function langmsg() { return lang($this->msg,$this->parms); } - - function error($etext, $parms, $ismsg) + function error($parms) { global $phpgw; - if (eregi('([IWEF])-(.*)[\,](.*)',$etext,$match)) + if ($parms == '') + { + return; + }; + $etext =$parms['text']; + $parray = array($parms['p1'],$parms['p2'],$parms['p3'],$parms['p4'],$parms['p5'],$parms['p6'],$parms['p7'],$parms['p8'],$parms['p9'],$parms['p10']); + $fname = $parms['file']; + $line = $parms['line']; + if (eregi('([DIWEF])-(.*)[\,](.*)',$etext,$match)) { $this->severity = strtoupper($match[1]); $this->code = $match[2]; @@ -51,14 +57,25 @@ $this->msg = trim($etext); } $this->timestamp = time(); - $this->parms = $parms; - $this->ismsg = $ismsg; - + $this->parms = $parray; + $this->ismsg = $parms['ismsg']; + $this->fname = $fname; + $this->line = $line; + $this->app = $phpgw_info['flags']['currentapp']; + + if (!$this->fname or !$this->line) + { + $phpgw->log->error(array('text'=>'W-PGMERR, Programmer failed to pass __FILE__ and/or __LINE__ in next log message', + 'file'=>__FILE__,'line'=>__LINE__ + ) + ); + } + $phpgw->log->errorstack[] = $this; if ($this->severity == 'F') { // This is it... Don't return - // do rollback... + // do rollback! // Hmmm this only works if UI!!!! // What Do we do if it's a SOAP/XML? echo "