63 lines
1.3 KiB
QML
63 lines
1.3 KiB
QML
// SPDX-FileCopyrightText: 2026, Shaun Reed <shaunrd0@gmail.com>
|
|
//
|
|
// SPDX-License-Identifier: GNU General Public License v3.0 or later
|
|
|
|
import QtQuick
|
|
import QtQuick.Controls
|
|
|
|
import clide.module 1.0
|
|
import Logger 1.0
|
|
|
|
Item {
|
|
ListModel {
|
|
id: model
|
|
|
|
}
|
|
Rectangle {
|
|
anchors.fill: parent
|
|
color: "#111"
|
|
}
|
|
ListView {
|
|
id: listView
|
|
|
|
function getLogColor(level) {
|
|
switch (level) {
|
|
case "INFO":
|
|
return RustColors.info_log;
|
|
case "DEBUG":
|
|
return RustColors.debug_log;
|
|
case "WARN":
|
|
return RustColors.warn_log;
|
|
case "ERROR":
|
|
return RustColors.error_log;
|
|
case "TRACE":
|
|
return RustColors.trace_log;
|
|
default:
|
|
return RustColors.info_log;
|
|
}
|
|
}
|
|
|
|
anchors.fill: parent
|
|
clip: true
|
|
model: model
|
|
|
|
delegate: Text {
|
|
color: listView.getLogColor(level)
|
|
font.family: "monospace"
|
|
text: `[${level}] ${message}`
|
|
}
|
|
|
|
onCountChanged: Qt.callLater(positionViewAtEnd)
|
|
}
|
|
Connections {
|
|
function onLogged(level, message) {
|
|
model.append({
|
|
level,
|
|
message
|
|
});
|
|
}
|
|
|
|
target: Logger
|
|
}
|
|
}
|