fix: remove filepath from text

This commit is contained in:
Igor Sirotin 2024-06-19 12:44:55 +01:00
parent 96e9ac064c
commit 2d5641460d
2 changed files with 13 additions and 6 deletions

View File

@ -1,4 +1,4 @@
import NimQml, chronicles, os, stew/shims/strformat, strutils, times, md5, json
import NimQml, chronicles, os, stew/shims/strformat, strutils, times, md5, json, re
import status_go
import keycard_go
@ -86,12 +86,19 @@ proc ensureDirectories*(dataDir, tmpDir, logDir: string) =
createDir(logDir)
proc logHandlerCallback(messageType: cint, message: cstring, category: cstring, file: cstring, function: cstring, line: cint) {.cdecl, exportc.} =
var text = $message
let fileString = $file
if fileString != "" and text.startsWith(fileString):
text = text[fileString.len..^1] # Remove filepath
text = text.replace(re"[:0-9]+:\s*") # Remove line, column, colons and space separator
logScope:
chroniclesLineNumbers = false
topics = "qt"
category = $category
file = $file & ":" & $line
text = $message
file = fileString & ":" & $line
text
case int(messageType):
of 0: # QtDebugMsg

View File

@ -197,13 +197,13 @@ void myMessageOutput(QtMsgType type, const QMessageLogContext &context, const QS
return;
}
QByteArray localMsg = msg.toLocal8Bit();
auto localMessage = msg.toLocal8Bit();
const char* message = localMessage.constData();
const char* category = context.category ? context.category : "";
const char* file = context.file ? context.file : "";
const char* function = context.function ? context.function : "";
int messageType = int(type);
const char* message = localMsg.constData();
messageHandlerCallback(messageType, message, category, file, function, context.line);
}