我使用@$this->dom->loadHTML($page);
来抑制错误,但CodeIgniter似乎不尊重......
日志中返回了一系列错误
错误 - 2012-07-17 16:36:27 - >严重性:警告 - > DOM文档:: loadHTML():
有没有办法只为一段代码或函数禁用日志记录?
答案 0 :(得分:1)
这与'尊重'@
无关,它与你误解了@
做什么以及CI如何与之相关。
函数前面的@
符号告诉PHP(不是CI)
当在PHP中添加表达式时,该表达式可能生成的任何错误消息都将被忽略。
参考: http://us3.php.net/manual/en/language.operators.errorcontrol.php
这基本上意味着它将“跳过”错误(否则你的执行会因任何错误而中断)。如果配置为CI,CI将 STILL 记录错误。
您必须编辑CI的配置,并定义您的日志记录级别:
/*
|--------------------------------------------------------------------------
| Error Logging Threshold
|--------------------------------------------------------------------------
|
| If you have enabled error logging, you can set an error threshold to
| determine what gets logged. Threshold options are:
| You can enable error logging by setting a threshold over zero. The
| threshold determines what gets logged. Threshold options are:
|
| 0 = Disables logging, Error logging TURNED OFF
| 1 = Error Messages (including PHP errors)
| 2 = Debug Messages
| 3 = Informational Messages
| 4 = All Messages
|
| For a live site you'll usually only enable Errors (1) to be logged otherwise
| your log files will fill up very fast.
|
*/
$config['log_threshold'] = 1;