CI 日志类

开发ci的过程中,使用log能直观的看出代码运行到哪,还可设置代码查看数据接口的发送情况。日志类:

<?php defined('BASEPATH') OR exit('No direct script access allowed');
/**
 * Logging Class
 */
class MY_Log extends CI_Log {

    public function info()
    {
        $msg = preg_replace("#
?
#", '', implode('', func_get_args()));
        return $this->write_log('INFO', $msg, FALSE);
    }

    public function error()
    {
        $msg = preg_replace("#
?
#", '', implode('', func_get_args()));
        return $this->write_log('ERROR', $msg, FALSE);
    }

    public function debug()
    {
        $msg = preg_replace("#
?
#", '', implode('', func_get_args()));
        return $this->write_log('DEBUG', $msg, FALSE);
    }
}
// END MY_Log Class

/* End of file MY_Log.php */
/* Location: ./application/libraries/MY_Log.php */

使用方法:

1. 自动加载log类: $autoload['libraries'] = array('log', 'session', 'curl', 'memcache');

2.输出log类:可在log文件中查看

 $this->log->debug('[GBOMP] 用户[' . $user . ']使用密码[' . $pass . ']尝试登录结果为:[' . print_r($info, TRUE) . ']');

原文地址:https://www.cnblogs.com/webskill/p/4962362.html