mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
install a message handler
Signed-off-by: Le Tan <tamlokveer@gmail.com>
This commit is contained in:
parent
7c69f80f17
commit
013b6cecc2
24
src/main.cpp
24
src/main.cpp
@ -5,8 +5,32 @@
|
|||||||
#include "utils/vutils.h"
|
#include "utils/vutils.h"
|
||||||
#include "vsingleinstanceguard.h"
|
#include "vsingleinstanceguard.h"
|
||||||
|
|
||||||
|
void VLogger(QtMsgType type, const QMessageLogContext &context, const QString &msg)
|
||||||
|
{
|
||||||
|
QByteArray localMsg = msg.toUtf8();
|
||||||
|
switch (type) {
|
||||||
|
case QtDebugMsg:
|
||||||
|
fprintf(stderr, "Debug:%s (%s:%u)\n", localMsg.constData(), context.file, context.line);
|
||||||
|
break;
|
||||||
|
case QtInfoMsg:
|
||||||
|
fprintf(stderr, "Info:%s (%s:%u)\n", localMsg.constData(), context.file, context.line);
|
||||||
|
break;
|
||||||
|
case QtWarningMsg:
|
||||||
|
fprintf(stderr, "Warning:%s (%s:%u)\n", localMsg.constData(), context.file, context.line);
|
||||||
|
break;
|
||||||
|
case QtCriticalMsg:
|
||||||
|
fprintf(stderr, "Critical:%s (%s:%u)\n", localMsg.constData(), context.file, context.line);
|
||||||
|
break;
|
||||||
|
case QtFatalMsg:
|
||||||
|
fprintf(stderr, "Fatal:%s (%s:%u)\n", localMsg.constData(), context.file, context.line);
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
qInstallMessageHandler(VLogger);
|
||||||
|
|
||||||
VSingleInstanceGuard guard;
|
VSingleInstanceGuard guard;
|
||||||
if (!guard.tryRun()) {
|
if (!guard.tryRun()) {
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user