mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-23 00:13:35 +01:00
__FILE__, __LINE__ parameters
This commit is contained in:
parent
402ab7a87b
commit
f83036ae9d
@ -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;
|
||||
|
@ -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 "<Center>";
|
||||
|
@ -27,34 +27,38 @@
|
||||
'astable',
|
||||
);
|
||||
|
||||
|
||||
function message($parms)
|
||||
{
|
||||
$etext =$parms['text'];
|
||||
$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',$etext,$parms,1);
|
||||
$parms['ismsg']=1;
|
||||
CreateObject('phpgwapi.error',$parms);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
function error($parms)
|
||||
{
|
||||
$etext =$parms['text'];
|
||||
$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',$etext,$parms,'');
|
||||
$parms['ismsg']=0;
|
||||
CreateObject('phpgwapi.error',$parms);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
function write($parms)
|
||||
{
|
||||
$etext =$parms['text'];
|
||||
$parms = array($parms['p0'],$parms['p1'],$parms['p2'],$parms['p3'],$parms['p4'],$parms['p5'],$parms['p6'],$parms['p7'],$parms['p8'],$parms['p9']);
|
||||
$parms['ismsg']=0;
|
||||
$save = $this->errorstack;
|
||||
$this->$errorstack = array();
|
||||
CreateObject('phpgwapi.error',$etext,$parms,1);
|
||||
CreateObject('phpgwapi.error',$parms);
|
||||
$this->commit();
|
||||
$this->errorstack = $save;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function iserror($parms)
|
||||
{
|
||||
$ecode = $parms['code'];
|
||||
@ -73,7 +77,7 @@
|
||||
|
||||
function severity()
|
||||
{
|
||||
$max = 'I';
|
||||
$max = 'D';
|
||||
$errorstack = $this->errorstack;
|
||||
reset($errorstack);
|
||||
while(list(,$err)=each($errorstack))
|
||||
@ -82,11 +86,15 @@
|
||||
{
|
||||
case 'F': return 'F'; break;
|
||||
case 'E': $max = 'E'; break;
|
||||
case 'W': if ($max == 'I')
|
||||
case 'W': if ($max != 'E')
|
||||
{
|
||||
$max = 'W';
|
||||
}
|
||||
break;
|
||||
case 'I': if ($max == 'D')
|
||||
{
|
||||
$max = 'I';
|
||||
}
|
||||
}
|
||||
}
|
||||
return $max;
|
||||
@ -97,7 +105,7 @@
|
||||
|
||||
global $phpgw, $phpgw_info;
|
||||
$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 "
|
||||
."('". $phpgw->db->to_timestamp(time()
|
||||
)
|
||||
@ -107,18 +115,19 @@
|
||||
.")"
|
||||
,__LINE__,__FILE__);
|
||||
|
||||
$db->query('select max(log_id) as lid from phpgw_log');
|
||||
$db->next_record();
|
||||
$log_id = $db->f('lid');
|
||||
$db->unlock();
|
||||
$log_id = $db->get_last_insert_id('phpgw_log','log_id');
|
||||
// $db->query('select max(log_id) as lid from phpgw_log');
|
||||
// $db->next_record();
|
||||
// $log_id = $db->f('lid');
|
||||
// $db->unlock();
|
||||
|
||||
$errorstack = $this->errorstack;
|
||||
for ($i = 0; $i < count($errorstack); $i++)
|
||||
{
|
||||
$err = $errorstack[$i];
|
||||
$db->query ("insert into phpgw_log_msg "
|
||||
."(Log_msg_log_id, log_msg_seq_no, log_msg_date, "
|
||||
."log_msg_severity, log_msg_code, log_msg_msg, log_msg_parms) values "
|
||||
."(Log_msg_log_id, log_msg_seq_no, log_msg_date, log_msg_severity, "
|
||||
."log_msg_code, log_msg_msg, log_msg_parms, log_msg_file, log_msg_line) values "
|
||||
."(" . $log_id
|
||||
."," . $i
|
||||
.", '" . $phpgw->db->to_timestamp($err->timestamp
|
||||
@ -127,12 +136,15 @@
|
||||
.", '". $err->code . "'"
|
||||
.", '". $err->msg . "'"
|
||||
.", '". addslashes(implode('|',$err->parms)). "'"
|
||||
.", '". $err->fname . "'"
|
||||
.", ". $err->line
|
||||
.")"
|
||||
,__LINE__,__FILE__);
|
||||
};
|
||||
unset ($errorstack);
|
||||
unset ($this->errorstack);
|
||||
$this->errorstack = array();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -150,6 +162,7 @@
|
||||
}
|
||||
unset ($this->errorstack);
|
||||
$this->errorstack = $new;
|
||||
return true;
|
||||
}
|
||||
|
||||
function astable()
|
||||
@ -165,6 +178,8 @@
|
||||
$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 >Msg</td>\n";
|
||||
$html .= "\t\t<td >File</td>\n";
|
||||
$html .= "\t\t<td >Line</td>\n";
|
||||
$html .= "\t</tr>\n";
|
||||
|
||||
$errorstack = $this->errorstack;
|
||||
@ -173,6 +188,7 @@
|
||||
$err = $errorstack[$i];
|
||||
switch ($err->severity)
|
||||
{
|
||||
case 'D': $color = 'D3DCFF'; break;
|
||||
case 'I': $color = 'C0FFC0'; break;
|
||||
case 'W': $color = 'FFFFC0'; break;
|
||||
case 'E': $color = 'FFC0C0'; break;
|
||||
@ -182,10 +198,12 @@
|
||||
$html .= "\t<tr bgcolor=".'"'.$color.'"'.">\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_info['flags']['currentapp']."  </td>\n";
|
||||
$html .= "\t\t<td>".$err->app."  </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->langmsg()."</td>\n";
|
||||
$html .= "\t\t<td>".$err->fname."</td>\n";
|
||||
$html .= "\t\t<td>".$err->line."</td>\n";
|
||||
$html .= "\t</tr>\n";
|
||||
};
|
||||
$html .= "</table>\n";
|
||||
|
@ -14,7 +14,7 @@
|
||||
/* Basic information about this app */
|
||||
$setup_info['phpgwapi']['name'] = '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']['enable'] = 3;
|
||||
$setup_info['phpgwapi']['app_order'] = 1;
|
||||
|
@ -2024,7 +2024,7 @@
|
||||
}
|
||||
|
||||
|
||||
$test[] = '0.9.13.007'; // version number?
|
||||
$test[] = '0.9.13.007';
|
||||
function phpgwapi_upgrade0_9_13_007()
|
||||
{
|
||||
global $setup_info, $phpgw_setup;
|
||||
@ -2035,4 +2035,16 @@
|
||||
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'];
|
||||
}
|
||||
|
||||
?>
|
||||
|
Loading…
Reference in New Issue
Block a user