我已经在config.php中将错误级别设置为1。但问题是我得到了很多错误,那就是NOT ACTUALLY ERRORS in terms of application logic。
考虑以下代码示例
$deleted = @unlink($filename);
$imap_uid = @imap_uid($con,$msgno);如你所见,上面的例子不会抛出错误,但如果发生错误,codeigniter会记录下来。
是否可以动态禁用错误日志记录?
我期待着这样的事情。
// ....
$this->error_log = 0; // disable error logging
//Perform some operation that which may log an error,even its suppressed
$this->error_log = 1; //enable it again
// ...谢谢。
发布于 2013-05-10 16:52:58
您可以扩展CI_Log类,为$_enabled添加setter
Class MY_Log extends CI_Log
{
function enable_logging($item=TRUE) {
$this->_enabled = (bool)$item;
}
}现在你可以这样做了
$this->log->enable_logging(FALSE);//禁用
$this->log->Enable_logging();//启用
发布于 2013-06-19 23:02:11
谢谢,基于Michail的回答,我有了这个使用受保护的$_threshold变量的更灵活的解决方案。
Class MY_Log extends CI_Log
{
public function setThreshold($l){
if(!in_array($l,array(0,1,2,3,4,5))){
log_message("error","MY_Log->setThreshold unsupported val: " . $l );
return false;
}
$this->_threshold = $l;
return true;
}
}在你的控制器上,你可以做到
$this->log->setThreshold(0);https://stackoverflow.com/questions/16476804
复制相似问题