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 status_go
|
||||||
import keycard_go
|
import keycard_go
|
||||||
|
@ -86,12 +86,19 @@ proc ensureDirectories*(dataDir, tmpDir, logDir: string) =
|
||||||
createDir(logDir)
|
createDir(logDir)
|
||||||
|
|
||||||
proc logHandlerCallback(messageType: cint, message: cstring, category: cstring, file: cstring, function: cstring, line: cint) {.cdecl, exportc.} =
|
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:
|
logScope:
|
||||||
chroniclesLineNumbers = false
|
chroniclesLineNumbers = false
|
||||||
topics = "qt"
|
topics = "qt"
|
||||||
category = $category
|
category = $category
|
||||||
file = $file & ":" & $line
|
file = fileString & ":" & $line
|
||||||
text = $message
|
text
|
||||||
|
|
||||||
case int(messageType):
|
case int(messageType):
|
||||||
of 0: # QtDebugMsg
|
of 0: # QtDebugMsg
|
||||||
|
|
|
@ -197,13 +197,13 @@ void myMessageOutput(QtMsgType type, const QMessageLogContext &context, const QS
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray localMsg = msg.toLocal8Bit();
|
auto localMessage = msg.toLocal8Bit();
|
||||||
|
const char* message = localMessage.constData();
|
||||||
const char* category = context.category ? context.category : "";
|
const char* category = context.category ? context.category : "";
|
||||||
const char* file = context.file ? context.file : "";
|
const char* file = context.file ? context.file : "";
|
||||||
const char* function = context.function ? context.function : "";
|
const char* function = context.function ? context.function : "";
|
||||||
|
|
||||||
int messageType = int(type);
|
int messageType = int(type);
|
||||||
const char* message = localMsg.constData();
|
|
||||||
messageHandlerCallback(messageType, message, category, file, function, context.line);
|
messageHandlerCallback(messageType, message, category, file, function, context.line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue