Browse Source

Log: add debug info to log in release build

Le Tan 7 years ago
parent
commit
be5e34cc85
3 changed files with 10 additions and 6 deletions
  1. 6 5
      src/main.cpp
  2. 1 1
      src/resources/themes/v_pure/v_pure.palette
  3. 3 0
      src/src.pro

+ 6 - 5
src/main.cpp

@@ -75,19 +75,18 @@ void VLogger(QtMsgType type, const QMessageLogContext &context, const QString &m
         break;
     }
 
+    QString fileName = QFileInfo(context.file).fileName();
 #if defined(QT_NO_DEBUG)
-    Q_UNUSED(context);
-
     QTextStream stream(&g_logFile);
-
-    stream << header << localMsg << "\n";
+    stream << header << (QString("(%1:%2) ").arg(fileName).arg(context.line))
+           << localMsg << "\n";
 
     if (type == QtFatalMsg) {
         g_logFile.close();
         abort();
     }
 #else
-    std::string fileStr = QFileInfo(context.file).fileName().toStdString();
+    std::string fileStr = fileName.toStdString();
     const char *file = fileStr.c_str();
 
     switch (type) {
@@ -168,6 +167,8 @@ int main(int argc, char *argv[])
 
     qInstallMessageHandler(VLogger);
 
+    qInfo() << "VNote started" << g_config->c_version << QDateTime::currentDateTime().toString();
+
     QString locale = VUtils::getLocale();
     // Set default locale.
     if (locale == "zh_CN") {

+ 1 - 1
src/resources/themes/v_pure/v_pure.palette

@@ -301,7 +301,7 @@ listview_item_selected_inactive_fg=@inactive_fg
 listview_item_selected_inactive_bg=@inactive_bg
 
 ; QAbstractItemView for TextEdit Completer.
-abstractitemview_textedit_fg=#content_fg
+abstractitemview_textedit_fg=@content_fg
 abstractitemview_textedit_bg=#DADADA
 abstractitemview_textedit_item_hover_fg=@abstractitemview_textedit_fg
 abstractitemview_textedit_item_hover_bg=@master_hover_bg

+ 3 - 0
src/src.pro

@@ -8,6 +8,9 @@ QT       += core gui webenginewidgets webchannel network svg printsupport
 
 greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
 
+# Enable message log in release build
+DEFINES += QT_MESSAGELOGCONTEXT
+
 TARGET = VNote
 TEMPLATE = app