Browse Source

Tweaks to logging output

- Worked on formatting of logging output, unable to use msg.replace since msg is a const &, but layout is fine now with endl and tabs.
- Only headers coloured, other text standard (except  Debug output, to differentiate it from logging)
- Removed OPL string from header
Felix Turo 3 years ago
parent
commit
2e86810bd9
5 changed files with 24 additions and 22 deletions
  1. 4 4
      src/classes/astyle.cpp
  2. 6 6
      src/functions/alog.cpp
  3. 10 8
      src/functions/alog.h
  4. 3 3
      src/gui/widgets/logbookwidget.cpp
  5. 1 1
      src/opl.h

+ 4 - 4
src/classes/astyle.cpp

@@ -51,7 +51,7 @@ void AStyle::setup()
         QFont font(ASettings::read(ASettings::Main::Font).toString());
         font.setPointSize(ASettings::read(ASettings::Main::FontSize).toUInt());
         qApp->setFont(font);
-        LOG << "Application Font set:\t" << font.toString().splitRef(',').first() << "\n";
+        LOG << "Application Font set: " << font.toString().splitRef(',').first();
     }
     // Set style, stylesheet or palette
     QString style_setting = ASettings::read(ASettings::Main::Style).toString();
@@ -88,7 +88,7 @@ void AStyle::resetStyle()
 void AStyle::setStyle(const QString &style_key)
 {
     resetStyle();
-    LOG << "Setting style:\t" << style_key;
+    LOG << "Setting style: " << style_key;
     QApplication::setStyle(QStyleFactory::create(style_key));
     currentStyle = style_key;
 }
@@ -96,7 +96,7 @@ void AStyle::setStyle(const QString &style_key)
 void AStyle::setStyle(const StyleSheet &style_sheet)
 {
     resetStyle();
-    LOG << "Setting stylesheet:\t" << style_sheet.styleSheetName;
+    LOG << "Setting stylesheet: " << style_sheet.styleSheetName;
     qApp->setStyleSheet(read_stylesheet(style_sheet.fileName));
     currentStyle = style_sheet.styleSheetName;
 }
@@ -104,7 +104,7 @@ void AStyle::setStyle(const StyleSheet &style_sheet)
 void AStyle::setStyle(const QPalette &palette)
 {
     resetStyle();
-    LOG << "Setting Colour Palette...\n";
+    LOG << "Setting Colour Palette...";
     qApp->setPalette(palette);
 }
 

+ 6 - 6
src/functions/alog.cpp

@@ -100,24 +100,24 @@ void aMessageHandler(QtMsgType type, const QMessageLogContext &context,
 
     switch (type) {
         case QtDebugMsg:
-            QTextStream(stdout) << DEB_HEADER_CONSOLE << msg << "\n\t" << function << "\033[m" << endl;
+            QTextStream(stdout) << DEB_HEADER_CONSOLE << msg << endl << D_SPACER << function << "\033[m" << endl;
             if(logDebug)
-                log_stream << timeNow() << DEB_HEADER << msg << "\t\t" << function << endl;
+                log_stream << timeNow() << DEB_HEADER << msg << D_SPACER << function << endl;
             break;
         case QtInfoMsg:
-            log_stream << timeNow() << INFO_HEADER << msg.chopped(2) << "\t\t" << function << endl;
+            log_stream << timeNow() << INFO_HEADER << msg << SPACER << function << endl;
             QTextStream(stdout) << INFO_HEADER_CONSOLE << msg << endl;
             break;
         case QtWarningMsg:
-            log_stream << timeNow() << WARN_HEADER << msg.chopped(2) << "\t\t" << endl;
+            log_stream << timeNow() << WARN_HEADER << msg << SPACER << endl;
             QTextStream(stdout) << WARN_HEADER_CONSOLE << msg << endl;
             break;
         case QtCriticalMsg:
-            log_stream << timeNow() << CRIT_HEADER << msg.chopped(2) << "\t\t" << endl;
+            log_stream << timeNow() << CRIT_HEADER << msg << SPACER << endl;
             QTextStream(stdout) << CRIT_HEADER_CONSOLE << msg << endl;
             break;
     default:
-            log_stream << QTime::currentTime().toString(Qt::ISODate) << INFO_HEADER << msg << function << endl;
+            log_stream << timeNow() << INFO_HEADER << msg << function << endl;
             QTextStream(stdout) << INFO_HEADER_CONSOLE << msg << endl;
             break;
     }

+ 10 - 8
src/functions/alog.h

@@ -54,14 +54,16 @@ namespace ALog
     const static int numberOfLogs = 10; // max number of log files to keep
     const static int sizeOfLogs = 1024 * 100; // max log size in bytes, = 100kB
 
-    const static auto DEB_HEADER  = QLatin1String(" [OPL - Deb ]: ");
-    const static auto INFO_HEADER = QLatin1String(" [OPL - INFO]: ");
-    const static auto WARN_HEADER = QLatin1String(" [OPL - WARN]: ");
-    const static auto CRIT_HEADER = QLatin1String(" [OPL - CRIT]: ");
-    const static auto DEB_HEADER_CONSOLE  = QLatin1String("\u001b[38;5;69m[OPL - Deb ]: ");
-    const static auto INFO_HEADER_CONSOLE = QLatin1String("\033[32m[OPL - INFO]: \033[m");
-    const static auto WARN_HEADER_CONSOLE = QLatin1String("\033[33m[OPL - WARN]: \033[m");
-    const static auto CRIT_HEADER_CONSOLE = QLatin1String("\033[35m[OPL - CRIT]: \033[m");
+    const static auto DEB_HEADER  = QLatin1String(" [DEBG]:\t");
+    const static auto INFO_HEADER = QLatin1String(" [INFO]:\t");
+    const static auto WARN_HEADER = QLatin1String(" [WARN]:\t");
+    const static auto CRIT_HEADER = QLatin1String(" [CRIT]:\t");
+    const static auto DEB_HEADER_CONSOLE  = QLatin1String("\u001b[38;5;75m[DEBG]:\t");
+    const static auto INFO_HEADER_CONSOLE = QLatin1String("\033[32m[INFO]:\t\033[m");
+    const static auto WARN_HEADER_CONSOLE = QLatin1String("\033[33m[WARN]:\t\033[m");
+    const static auto CRIT_HEADER_CONSOLE = QLatin1String("\033[35m[CRIT]:\t\033[m");
+    const static auto SPACER = QLatin1String("\t\t");
+    const static auto D_SPACER = QLatin1String("\t\t\t\t");
 
     bool init(bool log_debug = false);
     void setLogFileName();

+ 3 - 3
src/gui/widgets/logbookwidget.cpp

@@ -70,17 +70,17 @@ void LogbookWidget::setupModelAndView(int view_id)
 {
     switch (view_id) {
     case 0:
-        LOG << "Loading Default View...\n";
+        LOG << "Loading Default View...";
         displayModel->setTable(QStringLiteral("viewDefault"));
         displayModel->select();
         break;
     case 1:
-        LOG << "Loading EASA View...\n";
+        LOG << "Loading EASA View...";
         displayModel->setTable(QStringLiteral("viewEASA"));
         displayModel->select();
         break;
     default:
-        LOG << "Loading Default View...\n";
+        LOG << "Loading Default View...";
         displayModel->setTable(QStringLiteral("viewDefault"));
         displayModel->select();
     }

+ 1 - 1
src/opl.h

@@ -48,7 +48,7 @@ namespace Opl {
 
 #define DEB qDebug()                            // Use for debugging
 #define LOG qInfo()                             // Use for logging milestones (silently, will be written to log file and console out only)
-#define TODO qCritical() << "!\n\tTo Do:\t"
+#define TODO qCritical() << "TO DO:\t"
 
 #define INFO(msg) Opl::ANotificationHandler::info(msg, this)  // Use for messages of interest to the user (will be displayed in GUI)
 #define WARN(msg) Opl::ANotificationHandler::warn(msg, this)  // Use for warnings (will be displayed in GUI)