我想重写CI_Log类来改善日志行。 我想记录调用类的名称和方法。 例子:如何记录通话类信息?
DEBUG - 2011-04-23 09:21:29 - MY_Class - method --> Router Class Initialized
我试图重写write_log mehod这样的:
<?php if (! defined('BASEPATH')) exit('No direct script access allowed');
class MY_Log extends CI_Log {
public function write_log($level = 'error', $msg, $php_error = FALSE)
{
[...]
$message .=
$level .
(($level == 'INFO') ? ' - ' : ' - ') .
$this->router->fetch_class() .
' - ' .
$this->router->fetch_method() .
' - ' .
date($this->_date_fmt). ' --> ' .
$msg .
"\n";
[...]
}
}
但它不工作,$this->router
不能访问。 你能帮我吗?
当然,'$ this-> router'只能用于控制器,所以这不是一个好主意。我希望这为模型等工作... – 2011-04-23 08:30:29