fix: remove filepath from text
This commit is contained in:
parent
dda99d64c4
commit
f1043465cd
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue