status-desktop/storybook/Storybook/Logs.qml

36 lines
822 B
QML

import QtQuick 2.14
QtObject {
readonly property alias logText: d.logText
function logEvent(name, argumentNames, args) {
d.logText += d.createLog(name, argumentNames, args) + "\n"
}
readonly property QtObject _d: QtObject {
id: d
property string logText: ""
function createLog(name, argumentNames, args) {
let log = (new Date()).toLocaleTimeString(Qt.locale(), "h:mm:ss") + ": " + name
if (args.length === 0)
return log
log += ": ["
for (let i = 0; i < args.length; i++) {
log += argumentNames[i] + ": " + JSON.stringify(args[i])
if (i !== args.length - 1)
log += ", "
}
log += "]"
return log
}
}
}