feat: display logs in node management section

This commit is contained in:
Richard Ramos 2021-09-14 15:39:29 -04:00 committed by Iuri Matias
parent 22994a4a14
commit 03eed589a9
6 changed files with 52 additions and 5 deletions

View File

@ -238,7 +238,7 @@ DEFAULT_TENOR_API_KEY := DU7DWZ27STB2
TENOR_API_KEY ?= $(DEFAULT_TENOR_API_KEY)
NIM_PARAMS += -d:TENOR_API_KEY:"$(TENOR_API_KEY)"
NIM_PARAMS += -d:chronicles_sinks="textlines[stdout],textlines[nocolors,file]"
NIM_PARAMS += -d:chronicles_sinks=textlines[stdout],textlines[nocolors,dynamic],textlines[file,nocolors] -d:chronicles_runtime_filtering=on -d:chronicles_default_output_device=dynamic
RESOURCES_LAYOUT := -d:development

View File

@ -39,4 +39,7 @@ proc init*(self: NodeController) =
self.view.setStats(StatsSignal(e).stats)
self.view.fetchBitsSet()
self.status.events.on(SignalType.ChroniclesLogs.event) do(e:Args):
self.view.log(ChroniclesLogsSignal(e).content)
self.view.init()

View File

@ -200,3 +200,5 @@ QtObject:
QtProperty[int] peerSize:
read = getPeerSize
notify = peerSizeChanged
proc log*(self: NodeView, logContent: string) {.signal.}

View File

@ -30,9 +30,6 @@ proc mainProc() =
ensureDirectories(DATADIR, TMPDIR, LOGDIR)
let logFile = fmt"app_{getTime().toUnix}.log"
discard defaultChroniclesStream.output.open(LOGDIR & logFile, fmAppend)
var currentLanguageCode: string
let fleets =
@ -138,6 +135,18 @@ proc mainProc() =
defer:
signalsQObjPointer = nil
when compiles(defaultChroniclesStream.output.writer):
defaultChroniclesStream.output.writer =
proc (logLevel: LogLevel, msg: LogOutputStr) {.gcsafe, raises: [Defect].} =
try:
if signalsQObjPointer != nil:
signal_handler(signalsQObjPointer, ($(%* {"type": "chronicles-log", "event": msg})).cstring, "receiveSignal")
except:
logLoggingFailure(cstring(msg), getCurrentException())
let logFile = fmt"app_{getTime().toUnix}.log"
discard defaultChroniclesStream.outputs[1].open(LOGDIR & logFile, fmAppend)
var wallet = wallet.newController(status, appService)
defer: wallet.delete()
engine.setRootContextProperty("walletModel", wallet.variant)

View File

@ -69,6 +69,39 @@ Item {
}
}
ColumnLayout {
id: logContainer
height: 300
StyledText {
id: logHeaderDesc
color: Style.current.lightBlueText
text: "Logs:"
Layout.rightMargin: Style.current.padding
Layout.leftMargin: Style.current.padding
Layout.fillWidth: true
font.weight: Font.Medium
font.pixelSize: 20
}
StyledTextArea {
id: logsTxt
text: ""
customHeight: 200
textField.readOnly: true
}
Connections {
target: nodeModel
function onLog(logContent) {
let lines = logsTxt.text.split("\n");
if (lines.length > 5){
lines.shift();
}
lines.push(logContent.trim())
logsTxt.text = lines.join("\n")
}
}
}
ColumnLayout {
id: messageContainer
Layout.fillHeight: true

2
vendor/status-lib vendored

@ -1 +1 @@
Subproject commit 077965bf8120364b199af5c6ad3617aaa10734e4
Subproject commit 29b80979c6fcedc2e7dccfca109430312944d2c5