Qt 更改默认消息输出 qSetMessagePattern(const QString &pattern)

允许调整qDebug(), qInfo(), qWarning(), qCritical()和qFatal()的输出。 qCDebug()、qCInfo()、qCWarning()和qCCritical()的类别日志输出也被格式化。  

Example:

      QT_MESSAGE_PATTERN="[%{time yyyyMMdd h:mm:ss.zzz t} %{if-debug}D%{endif}%{if-info}I%{endif}%{if-warning}W%{endif}%{if-critical}C%{endif}%{if-fatal}F%{endif}] %{file}:%{line} - %{message}"
qSetMessagePattern("log[%{file} %{line} %{function} %{threadid}] %{message}");


%{appname}        QCoreApplication::applicationName() app名称
%{category}        Logging category 种类

%{file}                Path to source file 文件名

%{function}        Function 函数名

%{line}        Line in source file 文件行数

%{message}        The actual message 实际要输出 消息
%{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 obtained, the output is indeterminate (see QElapsedTimer::msecsSinceReference()).

消息时间  以系统引导开始计算,以秒为单位,如果无法获取引导时间输出结果不确定

%{time [format]}
        system time when the message occurred, formatted by passing the format to QDateTime::toString(). If the format is not specified, the format of Qt::ISODate is used.
消息发生时的系统时间,通过将格式传递给QDateTime::toString()进行格式化。 如果未指定格式,则使用Qt::ISODate格式。  

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值