thinkphp学习笔记(四)调试模式与日志记录
在华丽的分割线之下是需要修改和可以进行配置的具体实现方法:
cong.php
'配置值'//因为开启url重新不论是被重写的还是没被重写的,都可以通过原有路径访问//如果想开启rewrite模式,需要做如下操作//1.query服务器已经开启了apache的rewrite模块// loadmodule rewrite_module modules/mod_rewrite.so//2.在与主入口文件,统计目录下,新建一个.htaccess(vi:save .htaccess;记事本:.htaccess)//如果选用模式2(rewrite)会加大服务器的消耗'url_model'=>1,'url_patninfo_model'=>2,//pathinfo包含两类 //1普通模式:加上m和a:顺序关系可以发生变化 //http://localhost/mythinkphp/admin.php/m/index/a/index //传值 //http://localhost/mythinkphp/admin.php/m/index/a/index/username/zhangsan/password/password //2智能识别模块操作(默认模式就是智能识别) //http://localhost/mythinkphp/admin.php/index/index //传值 //http://localhost/mythinkphp/admin.php/index/index/username/zhangsan/password/password //修改url分隔符//'url_pathinfo_depr'=>'-',//修改模板左右定界符'tmpl_l_delim'=>'',//********************************非常华丽的分割线**************************************//开启调试模式//1.模拟linux系统来识别大小写//2.方法名的大小写与模板文件大小写有关'app_debug'=>true,//可以自定义页面的trace信息//配置文件路径的trace信息配置在thinkphp/tpl下的pagetrace.tpl.php//自定义方式://'tmpl_trace_file'=>app_path.'/public/trace.php',//或者自定义个trace.php页面放入当前的conf文件夹中//默认调试文件的位置://thinkphp/common/debug.php//不缓存数据库字段;如果开启,再修改可以将runtim/data下面的文件进行删除//'db_fields_cache'=> false,//可以自定义的debug.php放入当前的conf文件夹中//先将app_debug设置为false然后在加入下面参数//'app_debug'=>false,//显示运行次此页面需要的时间//'show_run_time'=>true,//显示详细的运行时间(基于show_run_time)//'show_adv_time'=>true,//显示数据库的操作次数(基于show_run_time)//'show_db_times'=>true,//显示缓存的操作次数(基于show_run_time)//'show_cache_times'=>true,//显示内存的开销(基于show_run_time)//'show_use_mem'=>true,//设置模板//'default_theme'=>'default',//日志处理log类:lib/think/core/log.class.php//开启日志'log_record'=>true,//日志处理log类:lib/think/core/log.class.php中有处理级别,可以选择性的加入'log_record_level'=>array('emerg','alert'),);?>
在action中使用:
//模型调试(数据库中执行的操作语句)$user=new model('user');$user->find(1);//获取最后一次执行的sqlecho $user->getlastsql();//使用:日志信息、日志级别、日志类型、具体信息log::write(aa,$level,$type,$file);//record方法将信息写入到内存当中