console.time 不支持 QLoggingCategory?
console.time doesn't support QLoggingCategory?
我试图通过创建许多日志记录类别来减少我的 QtQuick 应用程序中的日志输出量 like documented here。
A logging category can be passed to console.log() and friends as the first argument. If supplied to to the logger the LoggingCategory's name will be used as Logging Category otherwise the default logging category will be used.
现在我正在尝试用 console.time()
和 console.timeEnd()
(documented here) 来做到这一点。
我在日志输出中发现一些错误:
qrc:/main.qml:16: Error: console.time(): Invalid arguments
如何使用 console.time()
的日志记录类别?
示例代码:
import QtQuick 2.9
import QtQuick.Window 2.2
Window {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
LoggingCategory {
id: category
name: "some.not.so.important.stuff"
}
Component.onCompleted: {
console.time(category, 'start');
console.timeEnd(category, 'start');
}
}
文件中说的
A logging category can be passed to console.log() and friends as the
first argument
它指的是console.log、console.debug、console.info、console.warn和console.error,它们都是为了打印消息。
其他控制台功能(Assert、Timer 等)不支持日志记录类别。
我试图通过创建许多日志记录类别来减少我的 QtQuick 应用程序中的日志输出量 like documented here。
A logging category can be passed to console.log() and friends as the first argument. If supplied to to the logger the LoggingCategory's name will be used as Logging Category otherwise the default logging category will be used.
现在我正在尝试用 console.time()
和 console.timeEnd()
(documented here) 来做到这一点。
我在日志输出中发现一些错误:
qrc:/main.qml:16: Error: console.time(): Invalid arguments
如何使用 console.time()
的日志记录类别?
示例代码:
import QtQuick 2.9
import QtQuick.Window 2.2
Window {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
LoggingCategory {
id: category
name: "some.not.so.important.stuff"
}
Component.onCompleted: {
console.time(category, 'start');
console.timeEnd(category, 'start');
}
}
文件中说的
A logging category can be passed to console.log() and friends as the first argument
它指的是console.log、console.debug、console.info、console.warn和console.error,它们都是为了打印消息。
其他控制台功能(Assert、Timer 等)不支持日志记录类别。