__FILE__, __LINE__ parameters

This commit is contained in:
jerrywestrick 2001-08-08 07:21:29 +00:00
parent 402ab7a87b
commit f83036ae9d
5 changed files with 132 additions and 45 deletions

View File

@ -39,6 +39,7 @@
// Handle the Edit Table Button // Handle the Edit Table Button
if (isset($editable)) if (isset($editable))
{ {
@ -114,8 +115,11 @@
'log_msg_date_e', 'log_msg_date_e',
'log_msg_severity', 'log_msg_severity',
'log_msg_code', 'log_msg_code',
'log_msg_text' 'log_msg_text',
'log_msg_file',
'log_msg_line'
); );
// Store defaults in session data... // Store defaults in session data...
$phpgw->session->appsession ('session_data', $phpgw->session->appsession ('session_data',
'log', 'log',
@ -138,17 +142,51 @@
function list_log() function list_log()
{ {
global $phpgw, $phpgw_info; global $phpgw, $phpgw_info;
/*
$phpgw->log->write(array('text'=>'I-TestWrite, write: %1','p1'=>'This message should appear in log')); if (false) // add some errors to the 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')); // Test 1: single Error line immedeately to errorlog
$phpgw->log->clearstack(); // (could be type Debug, Info, Warning, or Error)
$phpgw->log->error(array('text'=>'I-TestInfo, info: %1','p1'=>'This Informational should be in log')); $phpgw->log->write(array('text'=>'I-TestWrite, write: %1','p1'=>'This message should appear in log','file'=>__FILE__,'line'=>__LINE__));
$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')); // Test 2: A message should appear in log even if clearstack is called
$phpgw->log->commit(); // commit error stack to log... $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')); $this->t->set_file(array('log_list_t' => 'log.tpl'));
/* /*
// --------------------------------- nextmatch --------------------------- // --------------------------------- nextmatch ---------------------------
@ -227,6 +265,7 @@ $phpgw->log->commit(); // commit error stack to log...
switch($row[$this->column['log_severity']]['value']) 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 'I': $row[$this->column['log_severity']]['bgcolor'] = 'C0FFC0'; break;
case 'W': $row[$this->column['log_severity']]['bgcolor'] = 'FFFFC0'; break; case 'W': $row[$this->column['log_severity']]['bgcolor'] = 'FFFFC0'; break;
case 'E': $row[$this->column['log_severity']]['bgcolor'] = 'FFC0C0'; 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']) switch($row[$this->column['log_msg_severity']]['value'])
{ {
case 'D': $color = 'D3DCFF'; break;
case 'I': $color = 'C0FFC0'; break; case 'I': $color = 'C0FFC0'; break;
case 'W': $color = 'FFFFC0'; break; case 'W': $color = 'FFFFC0'; break;
case 'E': $color = 'FFC0C0'; break; case 'E': $color = 'FFC0C0'; break;

View File

@ -23,24 +23,30 @@
var $parms = array(); var $parms = array();
var $ismsg = 0; var $ismsg = 0;
var $timestamp; var $timestamp;
var $fname;
var $line;
var $app;
var $public_functions = array(); var $public_functions = array();
/*******************************************\
* Constructor *
* to be accessed as new error() *
\*******************************************/
// Translate Message into Language // Translate Message into Language
function langmsg() function langmsg()
{ {
return lang($this->msg,$this->parms); return lang($this->msg,$this->parms);
} }
function error($parms)
function error($etext, $parms, $ismsg)
{ {
global $phpgw; 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->severity = strtoupper($match[1]);
$this->code = $match[2]; $this->code = $match[2];
@ -51,14 +57,25 @@
$this->msg = trim($etext); $this->msg = trim($etext);
} }
$this->timestamp = time(); $this->timestamp = time();
$this->parms = $parms; $this->parms = $parray;
$this->ismsg = $ismsg; $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; $phpgw->log->errorstack[] = $this;
if ($this->severity == 'F') if ($this->severity == 'F')
{ {
// This is it... Don't return // This is it... Don't return
// do rollback... // do rollback!
// Hmmm this only works if UI!!!! // Hmmm this only works if UI!!!!
// What Do we do if it's a SOAP/XML? // What Do we do if it's a SOAP/XML?
echo "<Center>"; echo "<Center>";

View File

@ -27,34 +27,38 @@
'astable', 'astable',
); );
function message($parms) function message($parms)
{ {
$etext =$parms['text']; $parms['ismsg']=1;
$parms = array($parms['p0'],$parms['p1'],$parms['p2'],$parms['p3'],$parms['p4'],$parms['p5'],$parms['p6'],$parms['p7'],$parms['p8'],$parms['p9']); CreateObject('phpgwapi.error',$parms);
CreateObject('phpgwapi.error',$etext,$parms,1); return true;
} }
function error($parms) function error($parms)
{ {
$etext =$parms['text']; $parms['ismsg']=0;
$parms = array($parms['p0'],$parms['p1'],$parms['p2'],$parms['p3'],$parms['p4'],$parms['p5'],$parms['p6'],$parms['p7'],$parms['p8'],$parms['p9']); CreateObject('phpgwapi.error',$parms);
CreateObject('phpgwapi.error',$etext,$parms,''); return true;
} }
function write($parms) function write($parms)
{ {
$etext =$parms['text']; $parms['ismsg']=0;
$parms = array($parms['p0'],$parms['p1'],$parms['p2'],$parms['p3'],$parms['p4'],$parms['p5'],$parms['p6'],$parms['p7'],$parms['p8'],$parms['p9']);
$save = $this->errorstack; $save = $this->errorstack;
$this->$errorstack = array(); $this->$errorstack = array();
CreateObject('phpgwapi.error',$etext,$parms,1); CreateObject('phpgwapi.error',$parms);
$this->commit(); $this->commit();
$this->errorstack = $save; $this->errorstack = $save;
return true;
} }
function iserror($parms) function iserror($parms)
{ {
$ecode = $parms['code']; $ecode = $parms['code'];
@ -73,7 +77,7 @@
function severity() function severity()
{ {
$max = 'I'; $max = 'D';
$errorstack = $this->errorstack; $errorstack = $this->errorstack;
reset($errorstack); reset($errorstack);
while(list(,$err)=each($errorstack)) while(list(,$err)=each($errorstack))
@ -82,11 +86,15 @@
{ {
case 'F': return 'F'; break; case 'F': return 'F'; break;
case 'E': $max = 'E'; break; case 'E': $max = 'E'; break;
case 'W': if ($max == 'I') case 'W': if ($max != 'E')
{ {
$max = 'W'; $max = 'W';
} }
break; break;
case 'I': if ($max == 'D')
{
$max = 'I';
}
} }
} }
return $max; return $max;
@ -97,7 +105,7 @@
global $phpgw, $phpgw_info; global $phpgw, $phpgw_info;
$db = $phpgw->db; $db = $phpgw->db;
$db->lock('phpgw_log'); // $db->lock('phpgw_log');
$db->query ("insert into phpgw_log (log_date, log_user, log_app, log_severity) values " $db->query ("insert into phpgw_log (log_date, log_user, log_app, log_severity) values "
."('". $phpgw->db->to_timestamp(time() ."('". $phpgw->db->to_timestamp(time()
) )
@ -107,18 +115,19 @@
.")" .")"
,__LINE__,__FILE__); ,__LINE__,__FILE__);
$db->query('select max(log_id) as lid from phpgw_log'); $log_id = $db->get_last_insert_id('phpgw_log','log_id');
$db->next_record(); // $db->query('select max(log_id) as lid from phpgw_log');
$log_id = $db->f('lid'); // $db->next_record();
$db->unlock(); // $log_id = $db->f('lid');
// $db->unlock();
$errorstack = $this->errorstack; $errorstack = $this->errorstack;
for ($i = 0; $i < count($errorstack); $i++) for ($i = 0; $i < count($errorstack); $i++)
{ {
$err = $errorstack[$i]; $err = $errorstack[$i];
$db->query ("insert into phpgw_log_msg " $db->query ("insert into phpgw_log_msg "
."(Log_msg_log_id, log_msg_seq_no, log_msg_date, " ."(Log_msg_log_id, log_msg_seq_no, log_msg_date, log_msg_severity, "
."log_msg_severity, log_msg_code, log_msg_msg, log_msg_parms) values " ."log_msg_code, log_msg_msg, log_msg_parms, log_msg_file, log_msg_line) values "
."(" . $log_id ."(" . $log_id
."," . $i ."," . $i
.", '" . $phpgw->db->to_timestamp($err->timestamp .", '" . $phpgw->db->to_timestamp($err->timestamp
@ -127,12 +136,15 @@
.", '". $err->code . "'" .", '". $err->code . "'"
.", '". $err->msg . "'" .", '". $err->msg . "'"
.", '". addslashes(implode('|',$err->parms)). "'" .", '". addslashes(implode('|',$err->parms)). "'"
.", '". $err->fname . "'"
.", ". $err->line
.")" .")"
,__LINE__,__FILE__); ,__LINE__,__FILE__);
}; };
unset ($errorstack); unset ($errorstack);
unset ($this->errorstack); unset ($this->errorstack);
$this->errorstack = array(); $this->errorstack = array();
return true;
} }
@ -150,6 +162,7 @@
} }
unset ($this->errorstack); unset ($this->errorstack);
$this->errorstack = $new; $this->errorstack = $new;
return true;
} }
function astable() function astable()
@ -165,6 +178,8 @@
$html .= "\t\t<td align=\"center\", width=\"2%\">S</td>\n"; $html .= "\t\t<td align=\"center\", width=\"2%\">S</td>\n";
$html .= "\t\t<td width=\"10%\">Error Code</td>\n"; $html .= "\t\t<td width=\"10%\">Error Code</td>\n";
$html .= "\t\t<td >Msg</td>\n"; $html .= "\t\t<td >Msg</td>\n";
$html .= "\t\t<td >File</td>\n";
$html .= "\t\t<td >Line</td>\n";
$html .= "\t</tr>\n"; $html .= "\t</tr>\n";
$errorstack = $this->errorstack; $errorstack = $this->errorstack;
@ -173,6 +188,7 @@
$err = $errorstack[$i]; $err = $errorstack[$i];
switch ($err->severity) switch ($err->severity)
{ {
case 'D': $color = 'D3DCFF'; break;
case 'I': $color = 'C0FFC0'; break; case 'I': $color = 'C0FFC0'; break;
case 'W': $color = 'FFFFC0'; break; case 'W': $color = 'FFFFC0'; break;
case 'E': $color = 'FFC0C0'; break; case 'E': $color = 'FFC0C0'; break;
@ -182,10 +198,12 @@
$html .= "\t<tr bgcolor=".'"'.$color.'"'.">\n"; $html .= "\t<tr bgcolor=".'"'.$color.'"'.">\n";
$html .= "\t\t<td align=center>".$i."</td>\n"; $html .= "\t\t<td align=center>".$i."</td>\n";
$html .= "\t\t<td>".$phpgw->common->show_date($err->timestamp)."</td>\n"; $html .= "\t\t<td>".$phpgw->common->show_date($err->timestamp)."</td>\n";
$html .= "\t\t<td>".$phpgw_info['flags']['currentapp']."&nbsp </td>\n"; $html .= "\t\t<td>".$err->app."&nbsp </td>\n";
$html .= "\t\t<td align=center>".$err->severity."</td>\n"; $html .= "\t\t<td align=center>".$err->severity."</td>\n";
$html .= "\t\t<td>".$err->code."</td>\n"; $html .= "\t\t<td>".$err->code."</td>\n";
$html .= "\t\t<td>".$err->langmsg()."</td>\n"; $html .= "\t\t<td>".$err->langmsg()."</td>\n";
$html .= "\t\t<td>".$err->fname."</td>\n";
$html .= "\t\t<td>".$err->line."</td>\n";
$html .= "\t</tr>\n"; $html .= "\t</tr>\n";
}; };
$html .= "</table>\n"; $html .= "</table>\n";

View File

@ -14,7 +14,7 @@
/* Basic information about this app */ /* Basic information about this app */
$setup_info['phpgwapi']['name'] = 'phpgwapi'; $setup_info['phpgwapi']['name'] = 'phpgwapi';
$setup_info['phpgwapi']['title'] = 'phpgwapi'; $setup_info['phpgwapi']['title'] = 'phpgwapi';
$setup_info['phpgwapi']['version'] = '0.9.13.008'; $setup_info['phpgwapi']['version'] = '0.9.13.009';
$setup_info['phpgwapi']['versions']['current_header'] = '1.17'; $setup_info['phpgwapi']['versions']['current_header'] = '1.17';
$setup_info['phpgwapi']['enable'] = 3; $setup_info['phpgwapi']['enable'] = 3;
$setup_info['phpgwapi']['app_order'] = 1; $setup_info['phpgwapi']['app_order'] = 1;

View File

@ -2024,7 +2024,7 @@
} }
$test[] = '0.9.13.007'; // version number? $test[] = '0.9.13.007';
function phpgwapi_upgrade0_9_13_007() function phpgwapi_upgrade0_9_13_007()
{ {
global $setup_info, $phpgw_setup; global $setup_info, $phpgw_setup;
@ -2035,4 +2035,16 @@
return $setup_info['phpgwapi']['currentver']; return $setup_info['phpgwapi']['currentver'];
} }
$test[] = '0.9.13.008';
function phpgwapi_upgrade0_9_13_008()
{
global $setup_info, $phpgw_setup;
$phpgw_setup->oProc->AddColumn('phpgw_log_msg','log_msg_file',array('type' => 'varchar', 'precision' => 255, 'nullable'=> False));
$phpgw_setup->oProc->AddColumn('phpgw_log_msg','log_msg_line',array('type' => 'int', 'precision' => 4, 'nullable'=> False));
$setup_info['phpgwapi']['currentver'] = '0.9.13.008';
return $setup_info['phpgwapi']['currentver'];
}
?> ?>