ThinkPHP学习笔记调试模式与日志记录
在华丽的分割线之下是需要修改和可以进行配置的具体实现方法:
cong.php
[php]
return array(
//更换模式最好删除一些~app.php和~runtime.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中使用:
[php]
//模型调试(数据库中执行的操作语句)
$User=new Model('User');
$User->find(1);
//获取最后一次执行的sql
echo $User->getLastSql();
//使用:日志信息、日志级别、日志类型、具体信息
Log::write("aa",$level,$type,$file);
//record方法将信息写入到内存当中

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



C++ multi-thread debugging can use GDB: 1. Enable debugging information compilation; 2. Set breakpoints; 3. Use infothreads to view threads; 4. Use thread to switch threads; 5. Use next, stepi, and locals to debug. Actual case debugging deadlock: 1. Use threadapplyallbt to print the stack; 2. Check the thread status; 3. Single-step the main thread; 4. Use condition variables to coordinate access to solve the deadlock.

How to use LeakSanitizer to debug C++ memory leaks? Install LeakSanitizer. Enable LeakSanitizer via compile flag. Run the application and analyze the LeakSanitizer report. Identify memory allocation types and allocation locations. Fix memory leaks and ensure all dynamically allocated memory is released.

This article introduces shortcuts for Go function debugging and analysis, including: built-in debugger dlv, which is used to pause execution, check variables, and set breakpoints. Logging, use the log package to record messages and view them during debugging. The performance analysis tool pprof generates call graphs and analyzes performance, and uses gotoolpprof to analyze data. Practical case: Analyze memory leaks through pprof and generate a call graph to display the functions that cause leaks.

Concurrency testing and debugging Concurrency testing and debugging in Java concurrent programming are crucial and the following techniques are available: Concurrency testing: Unit testing: Isolate and test a single concurrent task. Integration testing: testing the interaction between multiple concurrent tasks. Load testing: Evaluate an application's performance and scalability under heavy load. Concurrency Debugging: Breakpoints: Pause thread execution and inspect variables or execute code. Logging: Record thread events and status. Stack trace: Identify the source of the exception. Visualization tools: Monitor thread activity and resource usage.

Tools for debugging PHP asynchronous code include: Psalm: a static analysis tool that can find potential errors. ParallelLint: A tool that inspects asynchronous code and provides recommendations. Xdebug: An extension for debugging PHP applications by enabling a session and stepping through the code. Other tips include using logging, assertions, running code locally, and writing unit tests.

Common PHP debugging errors include: Syntax errors: Check the code syntax to make sure there are no errors. Undefined variable: Before using a variable, make sure it is initialized and assigned a value. Missing semicolons: Add semicolons to all code blocks. Function is undefined: Check that the function name is spelled correctly and make sure the correct file or PHP extension is loaded.

The following techniques are available for debugging recursive functions: Check the stack traceSet debug pointsCheck if the base case is implemented correctlyCount the number of recursive callsVisualize the recursive stack

Logging optimization tip: Disable debug logging to eliminate the impact. Batch log messages to reduce overhead. Use asynchronous logging to offload logging operations. Limit log file size to improve application startup and processing performance.
