我想重寫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