Add basic debug logger.
This commit is contained in:
58
qml/ClideLogger.qml
Normal file
58
qml/ClideLogger.qml
Normal file
@@ -0,0 +1,58 @@
|
||||
// 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
|
||||
anchors.fill: parent
|
||||
model: model
|
||||
clip: true
|
||||
|
||||
function getLogColor(level) {
|
||||
switch (level) {
|
||||
case "INFO":
|
||||
return RustColors.info_log
|
||||
break;
|
||||
case "DEBUG":
|
||||
return RustColors.debug_log
|
||||
break;
|
||||
case "WARN":
|
||||
return RustColors.warn_log
|
||||
break;
|
||||
case "ERROR":
|
||||
return RustColors.error_log
|
||||
break;
|
||||
default:
|
||||
return RustColors.info_log
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
delegate: Text {
|
||||
text: `[${level}] ${message}`
|
||||
font.family: "monospace"
|
||||
color: listView.getLogColor(level)
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: Logger
|
||||
function onLogged(level, message) {
|
||||
model.append({ level, message })
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user