Qt中debug和release状态下输出内容有所不同,debug模式下包含了数百条警告及错误日志,除非在编译期间设置了QT_NO_WARNING_OUTPUT和/或QT_NO_DEBUG_OUTPUT,否则在发布模式下构建的Qt也包含此类警告。
一 格式化日志
qt 格式化输出内容有两种方法: qInstallMessageHandler 和 qSetMessagePattern
qSetMessagePattern 使用方法
Placeholder |
Description |
%{appname} |
|
%{category} |
Logging category |
%{file} |
Path to source file |
%{function} |
Function |
%{line} |
Line in source file |
%{message} |
The actual message |
%{pid} |
|
%{threadid} |
The system-wide ID of current thread (if it can be obtained) |
%{qthreadptr} |
A pointer to the current QThread (result of QThread::currentThread()) |
%{type} |
"debug", "warning", "critical" or "fatal" |
%{time process} |
time of the message, in seconds since the process started (the token "process" is literal) |
%{time boot} |
the time of the message, in seconds since the system boot if that can be determined (the token "boot" is literal). If the time since boot could not be obtai |